Welcome to MacForumz.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

[XCode] adding a task to the build phase

 
   Macintosh computer (Home) -> Tools RSS
Related Topics:
XCode build hangs. Why? - I've just started playing around with XCode and have run into a few problems. I have a simple BSD static library project with C++ source files. When a build fails due to source file errors XCode seems to hang as though the build process hasn't ended...

XCode Build hang - I'm building a standard Tool (i.e. command line app) in XCode and it will hang doing a build. By this I don't mean XCode stops, all windows and controls are still but it does not finish the build. The Build button is greyed out..

How to build Fat binaries - I wanted for an to build a fat binary using XCode 2.1. (Hello world command line test). So I created a test project (command line utility -> Standard Tool). I then picked the target and under the Build tab, I selected and picked..

PB build wanings - gcc3 issue? - I'm using Jaguar, PB and IB. It was all working fine but recently when I build I get a stream of warnings about gcc3 not having the same time as precomp? (There are also some messages in the middle pane that suggest that its using

Build executables for other Unix platforms? - Is it possible with gcc on to build for other Unix I notice gcc has options like but man says only available "On System V.4 and embedded PowerPC I would be in doing builds for..
Next:  Tools: Creating Services Advertisements in XCode 2.4  
Author Message
pere.noel

External


Since: Jan 21, 2006
Posts: 40



(Msg. 1) Posted: Tue Nov 28, 2006 11:48 am
Post subject: [XCode] adding a task to the build phase
Archived from groups: comp>sys>mac>programmer>tools (more info?)

Hey all,

i'd like to add a build phase into my target.

in case of build success create a dmg archive of the resulting app and
put that in the dist folder of the project.

do u have some link about that ?

Yvon

--
une bévue

 >> Stay informed about: [XCode] adding a task to the build phase 
Back to top
Login to vote
David Phillip Oste

External


Since: Apr 25, 2004
Posts: 1081



(Msg. 2) Posted: Tue Nov 28, 2006 3:17 pm
Post subject: Re: [XCode] adding a task to the build phase [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <1hpigln.17bfwzh1vtkohhN%pere.noel@laponie.com.invalid>,
pere.noel.DeleteThis@laponie.com.invalid (Une bévue) wrote:

> i'd like to add a build phase into my target.
>
> in case of build success create a dmg archive of the resulting app and
> put that in the dist folder of the project.
>
> do u have some link about that ?
>

I add a new target called "Package" that depends on the previous target,
so it only runs when the previous target succeeds. It has only a single
shell script build phase, that runs a separate text file (so it is easy
to edit and not part of the .xcodeproj file.)

That shell script starts with:
#!/bin/sh
if [ $ACTION == "build" ] && [ $BUILD_VARIANTS == "normal" ] && [ `basename $BUILT_PRODUCTS_DIR` == "Release" ] ; then


end ends with


fi


In between, I use:
# This is the simple name of my product. A passed shell variable would probably be better here.
RESULT_NAME="My Product"

# VERSION - the version string. note the backquotes
VERSION=`defaults read "$BUILT_PRODUCTS_DIR/$RESULT_NAME.app/Contents/Info" CFBundleShortVersionString`


# FULL_NAME - append the version.
FULL_NAME="$RESULT_NAME $VERSION"


# use a prototype dmg that was previously hand made to hold a volume called "My Product", same as $RESULT_NAME
# copy a prototype DMG to the output directory
cp -f "Prototype.dmg" "$BUILT_PRODUCTS_DIR/$RESULT_NAME Work.dmg"

# Use the "find" command to remove .DS_Store files and .h files from the result.
# left as an exercise for the reader.

# mount it.
hdiutil attach "$BUILT_PRODUCTS_DIR/$RESULT_NAME Work.dmg" -quiet

# need Finder to do this next rename. "mv" will not work here
osascript -e tell\ application\ \"Finder\"\ to\ set\ name\ of\ disk\ \""$RESULT_NAME"\"\ to\ \""$FULL_NAME"\"

# " this comment is just to keep Xcode syntax coloring sane

#give Finder time to settle down.
sleep 2

# put the app into the disk image
cp -R "$BUILT_PRODUCTS_DIR/$RESULT_NAME"/* "/Volumes/$FULL_NAME"

# convert to read-only, compressed
hdiutil convert "$BUILT_PRODUCTS_DIR/$RESULT_NAME Work.dmg" -format UDZO -imagekey zlib-level=9 -o "$BUILT_PRODUCTS_DIR/$RESULT_NAME.dmg" -quiet














If you rename the disk represented by the .dmg, you'll also need
to use an applescript to reset the volume's background image,
since the Finder stores the path to the volume's background image
using an absolute pathname.


--
David Phillip Oster

 >> Stay informed about: [XCode] adding a task to the build phase 
Back to top
Login to vote
pere.noel

External


Since: Jan 21, 2006
Posts: 40



(Msg. 3) Posted: Tue Nov 28, 2006 4:48 pm
Post subject: Re: [XCode] adding a task to the build phase [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

David Phillip Oster <oster.TakeThisOut@ieee.org> wrote:

>
> I add a new target called "Package" that depends on the previous target,
> so it only runs when the previous target succeeds. It has only a single
> shell script build phase, that runs a separate text file (so it is easy
> to edit and not part of the .xcodeproj file.)

Ok i see what you mean, then it isn't a new build phase but rather a new
target one (i'm following your above writing within XCode).

That's realy nice i've just added a new project > target > shell script
target.

in the window « Run Script Phase "Package" Info » their is a textfield
right to the first label "Shell", actually it's writen, by default
"/bin/sh" i think i could change that to any shell script including ruby
calling applescript ?

It seems to be so easy to do that i want to insure myself ;-)

>
> That shell script starts with:

<snip/>

>
> If you rename the disk represented by the .dmg, you'll also need
> to use an applescript to reset the volume's background image,
> since the Finder stores the path to the volume's background image
> using an absolute pathname.

fine thanks very much, i appreciate.

yes i know for the background image BUT i've nerver been able to get
size of opened dmg window +/-= size of background image (on the end user
side) even if i do something like :

tell the_window
set the_bounds to bounds of the_window
set item 3 of the_bounds to (item 1 of the_bounds) + 545
set item 4 of the_bounds to (item 2 of the_bounds) + 355
set its bounds to the_bounds
end tell

545x355 being the size of the background image + borders thickness.

it seems these bounds aren't save even if i detach re-attach de dmg...

do you have solved that tricky point (at least for me) ?

anyway thanks for youur reply it helps me a lot !

--
une bévue
 >> Stay informed about: [XCode] adding a task to the build phase 
Back to top
Login to vote
David Phillip Oste

External


Since: Apr 25, 2004
Posts: 1081



(Msg. 4) Posted: Wed Nov 29, 2006 6:56 am
Post subject: Re: [XCode] adding a task to the build phase [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <1hpitig.1x2ba371l4mlrxN%pere.noel@laponie.com.invalid>,
pere.noel.RemoveThis@laponie.com.invalid (Une bévue) wrote:

> Ok i see what you mean, then it isn't a new build phase but rather a new
> target one (i'm following your above writing within XCode).

A new build phase would also work, but I wanted an easy way to choose
between building an install image and not, so I wouldn't have to wait
for it to build when debugging.

> in the window Run Script Phase "Package" Info their is a textfield
> right to the first label "Shell", actually it's writen, by default
> "/bin/sh" i think i could change that to any shell script including ruby
> calling applescript ?

Yes, you can use any program you like to interpret the script.

> yes i know for the background image BUT i've nerver been able to get
> size of opened dmg window +/-= size of background image (on the end user
> side) even if i do something like :
>
> tell the_window
> set the_bounds to bounds of the_window
> set item 3 of the_bounds to (item 1 of the_bounds) + 545
> set item 4 of the_bounds to (item 2 of the_bounds) + 355
> set its bounds to the_bounds
> end tell
>
> 545x355 being the size of the background image + borders thickness.
>
> it seems these bounds aren't save even if i detach re-attach de dmg...
>
> do you have solved that tricky point (at least for me) ?

I've found that if the applescript brings the finder to the front, and
it resizes the window, then ejects the disk, that the window's size is
written to the disk.
 >> Stay informed about: [XCode] adding a task to the build phase 
Back to top
Login to vote
pere.noel

External


Since: Jan 21, 2006
Posts: 40



(Msg. 5) Posted: Wed Nov 29, 2006 2:56 pm
Post subject: Re: [XCode] adding a task to the build phase [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

David Phillip Oster <oster.DeleteThis@ieee.org> wrote:

> > Ok i see what you mean, then it isn't a new build phase but rather a new
> > target one (i'm following your above writing within XCode).
>
> A new build phase would also work, but I wanted an easy way to choose
> between building an install image and not, so I wouldn't have to wait
> for it to build when debugging.

OK i see...

<snip/>

> >
> > it seems these bounds aren't save even if i detach re-attach de dmg...
> >
> > do you have solved that tricky point (at least for me) ?
>
> I've found that if the applescript brings the finder to the front, and
> it resizes the window, then ejects the disk, that the window's size is
> written to the disk.

just to add frontmost then... :-)

fine, thanks again !
--
une bévue
 >> Stay informed about: [XCode] adding a task to the build phase 
Back to top
Login to vote
David Phillip Oste

External


Since: Apr 25, 2004
Posts: 1081



(Msg. 6) Posted: Wed Nov 29, 2006 3:10 pm
Post subject: Re: [XCode] adding a task to the build phase [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <1hpkhv9.p5uil31x405llN%pere.noel@laponie.com.invalid>,
pere.noel RemoveThis @laponie.com.invalid (Une bévue) wrote:

> > I've found that if the applescript brings the finder to the front, and
> > it resizes the window, then ejects the disk, that the window's size is
> > written to the disk.
>
> just to add frontmost then... :-)

activate

>
> fine, thanks again !

Apparently if you tell the Finder to do too many things between the
mount and the eject, then the Finder decides you didn't really mean to
record the window size.
 >> Stay informed about: [XCode] adding a task to the build phase 
Back to top
Login to vote
pere.noel

External


Since: Jan 21, 2006
Posts: 40



(Msg. 7) Posted: Wed Nov 29, 2006 6:32 pm
Post subject: Re: [XCode] adding a task to the build phase [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

David Phillip Oster <oster.DeleteThis@ieee.org> wrote:

> activate
>
> >
> > fine, thanks again !
>
> Apparently if you tell the Finder to do too many things between the
> mount and the eject, then the Finder decides you didn't really mean to
> record the window size.

that's funny finder )))

--
une bévue
 >> Stay informed about: [XCode] adding a task to the build phase 
Back to top
Login to vote
Display posts from previous:   
   Macintosh computer (Home) -> Tools All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]