bright pebbles dot org
alternative OS experience (all but windows)
Many developers usually package their applications in Mac OS X disk images (.dmg) because it is a simple and safe way to transfer data over the internet. By storing your applications in a disk image, you get for free: * compression * self-extraction * license agreement dialog
Creating a disk image manually, however, is a waste of time, especially when releases are frequent. Even if it consists in a quick drag and drop! Moreover, you have to pay to get a dmg builder application that allows to add license agreements.
In a few steps, thanks to a little piece of software – buildDMG – freely available but nevertheless complete, we can configure a Xcode project to create a disk image of our application at the end of the build process (but you could use it for make-based projects too).
BuildDMG is a command line tool for creating disk images. It is actually a perl script that invokes the tool hdiutil, so it has most of the options the latter has, but it also allows the creation of images with a license agreement.
Download buildDMG.pl and copy it where you want, maybe in a folder of your $PATH variable.
BuildDMG ships with a resource file called SLA.r that contains the code needed to create an image with a license agreement.
Add this file in your Xcode project and replace the license agreement text in the block of type TEXT, id 5002, if the existing one does not fit your needs:
data 'TEXT' (5002, "English") {
"Copyright (c) 2005 Salvatore Montefusco. All rights reserved.\n"
"\n"
...
}
Add a new shell script build phase and insert the following lines. First of all, we want to execute the script only in the deployment builds:
if [ $BUILD_STYLE != "Deployment" ]; then
exit
fi
Note:
checking the box ‘Run script only during deployment builds’ actually lets the script run only when a project is installed with xcodebuild install from the terminal.
Then we create an internet enabled, compressed image with the license agreement we have created above and we use the build settings provided by Xcode:
/path/to/buildDMG.pl -dmgName $PRODUCT_NAME \
-buildDir $SYMROOT \
-volName $PRODUCT_NAME \
-compressionLevel 9 \
-slaRsrcFile $SRCROOT/SLA.r \
-deleteHeaders \
-internetEnabled \
$SYMROOT/$FULL_PRODUCT_NAME
Note:
at the time we are writing, a bug in buildDMG causes the last part of a dmg name followed by dot numbers, e.g. My_App1.3.2, to be trimmed in My_App1.3. A workaround is to put a fake .0 at the end of the name: $PRODUCT_NAME.0.
Then we want the image to be gzipped:
/usr/bin/gzip -f $SYMROOT/$PRODUCT_NAME.dmg
In the Input Files table, add the following lines:
$(SRCROOT)/DMG_License.r
$(SYMROOT)/$(FULL_PRODUCT_NAME)
and in the Output Files table, add:
$(SYMROOT)/$(PRODUCT_NAME).dmg.gz
Build your project in deployment style to make the script run. A new gzipped disk image will appair in the build folder of your project.
Comments
uhh... sounds great!! Is there an english translation?
thanks for this great resource.
just that I'm not very familiar with unix and sh scripts
or build phase scripts
tried to follow directions
concatenated those snippets into one script (right?)
script was even saved by xcode to the project.build/Release/Project.build/ direcory
but
no results
anyone care to offer a step-by-step for the uninitiated...?
Thanks!
Post new comment