Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Xcode Auto-increment Build Number

Auto-increment build number in Xcode

Automatically increment the build number every time the project is compiled.

Usage

  • Select your target in your Xcode project
  • Select the Build Phases tab
  • Add a New Run Script Phase entry (via the + sign)
  • Copy the snippet below into the shell editor
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}"

Make sure that your starting build number (General tab, below the version number) is set to a whole integer and not a float, e.g. 1, not 1.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.