Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcandreappel/539a494dffbedfcb201c559d1fd78433 to your computer and use it in GitHub Desktop.
Save marcandreappel/539a494dffbedfcb201c559d1fd78433 to your computer and use it in GitHub Desktop.
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