It assumes the following about your versions in info.plist:
- Your product version is CFBundleShortVersionString in info.plist
eg 1.0.0
- Your build number is appended to your product version in CFBundleVersion
eg 1.0.0.133
- Enter some default values in info.plist
Bundle versions string, short: 0.1.0 (CFBundleShortVersionString)
Bundle version: 0.1.0.1 (CFBundleVersion) - Select your Target in Xcode
- Add a new run script build phase:
Project -> New Build Phase -> New Run Script Build Phase - Paste the script below into the script box
- Build your project
/^[[:blank:]]*
N
s/^[[:blank:]]*
p
}' info.plist)
build=$(sed -n '
/^[[:blank:]]*
N
s/^[[:blank:]]*
p
}' info.plist)
build=$(($build +1))
cp Info.plist 'Backup of Info.plist'
sed '
/^[[:blank:]]*
N
s/\(
P
D
}' 'Backup of info.plist' > Info.plist
Each time you build using that target the build number will be incremented. A backup of your info.plist is made (just in case).
You could easily extend this script to commit files to your subversion repository.
The script uses multi-line sed and I'm no sed magician. If you're looking for a sed tutorial try here.