One feature that is strangely missing from Xcode is the option to auto increment the build number on each build. However, with the run-script feature of the build-phase it’s easy to fix.
- On the project summary tab set the build number to an integer.
- Go to the build phases tab & click ‘Add build phase/add run script
- Enter the code below. Make sure ‘shell’ is set to /bin/bash
- Drag script to before ‘Copy Bundle Resources’
buildNumber=$(/usr/libexec/PlistBuddy -c “Print CFBundleVersion” “$INFOPLIST_PATH”)
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c “Set :CFBundleVersion $buildNumber” “$INFOPLIST_PATH”
XCode 4.3 caches info.plist, so the build number isn’t always shown correctly on the summary page, but it will have been updated correctly in the file.