Wojtek @suda Siudzinski

Python/Node/Golang/Rust developer, DIY hacker, rookie designer, 3D print junkie. CEO @ Gaia Charge

Auto Increment Build Number in Xcode 4.2 (fixed)

When testing your apps with TestFlight, it's good to set newer build version when uploading another version, because it helps to differentiate between them and also if you use takeOff: message using their API, user with an old version, will see a message informing that there's a new version to download.

One query to Google, and we have a automatic solution. It's great, but it could use PROJECT_NAME setting, to locate plist file, so it works in every project without changing (also Xcode now uses CFBundleVersion instead of CWBuildNumber):

buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" ${PROJECT_DIR}/${PROJECT_NAME}/${PROJECT_NAME}-Info.plist)
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" ${PROJECT_DIR}/${PROJECT_NAME}/${PROJECT_NAME}-Info.plist

Now just add "Run Script" build phase with this script (remember to move it before "Copy Bundle Resources" phase) and set your CFBundleVersion to an integer.

comments powered by Disqus