Xcode Build Number Script

I usually use a script to increment the build number of my apps in Xcode. I found this script on Stack Overflow a while ago, but I can’t find the question anymore.


Here it is:


1
2
3
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"


You just add it as a Run Script Build Phase.


Now, when you build the app, the build number will automatically be incremented by 1. That’s it.