Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer Tools > Re: [XCode] add...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 7 Topic 563 of 635
Post > Topic >>

Re: [XCode] adding a task to the build phase

by David Phillip Oster <oster@[EMAIL PROTECTED] > Nov 28, 2006 at 03:17 PM

In article <1hpigln.17bfwzh1vtkohhN%pere.noel@[EMAIL PROTECTED]
>,
 pere.noel@[EMAIL PROTECTED]
 (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
 




 7 Posts in Topic:
[XCode] adding a task to the build phase
pere.noel@[EMAIL PROTECTE  2006-11-28 11:48:19 
Re: [XCode] adding a task to the build phase
David Phillip Oster <o  2006-11-28 15:17:03 
Re: [XCode] adding a task to the build phase
pere.noel@[EMAIL PROTECTE  2006-11-28 16:48:45 
Re: [XCode] adding a task to the build phase
David Phillip Oster <o  2006-11-29 06:56:12 
Re: [XCode] adding a task to the build phase
pere.noel@[EMAIL PROTECTE  2006-11-29 14:56:49 
Re: [XCode] adding a task to the build phase
David Phillip Oster <o  2006-11-29 15:10:31 
Re: [XCode] adding a task to the build phase
pere.noel@[EMAIL PROTECTE  2006-11-29 18:32:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 13 9:10:33 CDT 2008.