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


|