Database Reference
In-Depth Information
Example 3-3. A perl script to set the build number in the version string
cd BuggyWhipChat/BuggyWhipChat
/usr/bin/perl -p -i -e "s/BUILDNUM/$BUILD_NUMBER/g" BuggyWhipChat-Info.plist
So what's going on here? First, we move ourselves to the right directory with cd , in this
case the subdirectory that contains the plist file we want to modify. Then we use a perl
“in-place” edit to substitute the string BUILDNUM for the BUILD_NUMBER environment vari-
able globally in the file. Since this step occurs before xcodebuild is run, the version
number in the binary will reflect the build number we set.
If we run the build again (after checking the modified plist file into CVS, of course), we
can verify that the step ran by looking at the build console output, which will now
contain this snippet:
$ computing changelog[workspace]
$ /bin/sh -xe /Volumes/Homes/Diane/tomcat/temp/hudson3475590830804804920.sh
+ cd BuggyWhipChat/BuggyWhipChat
+ /usr/bin/perl -p -i -e s/BUILDNUM/6/g BuggyWhipChat-Info.plist
In this case, BUILDNUM is being replaced by 6, the current build number. If we take a peek
at the plist in the finished build workspace directory (which hides in ~/.hudson/jobs/
buildname /workspace/ ), we can also see that the strings were appropriately modified in
the actual file:
<key>CFBundleShortVersionString</key>
<string>1.0.6</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.6</string>
Parameterize the Build Script
As you go along, you're going to end up running a number of different Xcode builds
as part of your automated build process. You'll be running unit-test-only builds, debug
builds, Ad Hoc builds, and maybe even App Store builds. They all are the same, except
for the scheme and action you specify to xcodebuild —so why not make a parameterized
custom Ant task, and save some copy-and-paste scripting?
Go back into your build.xml file, and change it to look like Example 3-4 .
Example 3-4. A parameterized build.xml file
<?xml version="1.0" encoding="utf-8"?>
<project name="Buggy Whip Builder" default="debugbuild" basedir=".">
<macrodef name="xcodebuild">
<attribute name="workspace"/>
<attribute name="scheme"/>
<attribute name="action" default="build"/>
<sequential>
 
Search WWH ::




Custom Search