In order to put in place a continuous integration system, Hudson, I wrote a bash script to build Xcode project automatically. Moreover, in Debug configuration, It was asked to me, to insert the svn revision number of the project in the CFBundleRevision field of the PROJECT-Info.plist file as ${BUNDLE_VERSION}.r${SVN_REVISION}.
You'll find the source code of PROJECT-Info.plist file below :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
[...]
<key>CFBundleVersion</key>
<string>1.0</string>
[...]
</dict>
</plist>
I tried this bash script below :
sed 'N;s_^.*<key>CFBundleVersion</key>.*<string>[0-9][0-9]*\.[0-9][0-9]*</string>$_<key>CFBundleVersion</key>\
<string>'"$BUNDLE_VERSION"'\.r'"$SVN_REVISION"'</string>_' $PROJECT-Info.plist
This script should replace the "1.0" string with ${BUNDLE_VERSION}.r${SVN_REVISION} (just in standard output currently).
However, the replacement works without the 'N' option which includes the next line in the sed process and for one line at a time. But there is many line with "<string>[...]</string>
" string in the PROJECT-Info.plist file...
I think it's my way of processing the unknown characters between the two lines ('N' option and ".*" for any characters) is wrong.
Any idea ?
Thanks in advance and sorry for my bad level in English.
Use PlistBuddy:
# cf. http://davedelong.com/blog/2009/04/15/incrementing-build-numbers-xcode
/usr/libexec/PlistBuddy -h
/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" test.plist
myversion=1.0.5
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion '${myversion}'" test.plist
In this specific case you can also use Xcode's agvtool
. You do not even need to provide the path to the PROJECT-Info.plist file. Inside your project dir run:
agvtool new-version -all "$BUILD_NUMBER" # sets CFBundleVersion
agvtool new-marketing-version "$BUNDLE_VERSION" # sets CFBundleShortVersionString
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With