Set Xcode build numbers to incremented or timestamps


title: Set Xcode build numbers to incremented or timestamps published: true description: tags: //cover_image: https://direct_url_to_image.jpg

Never again should you need to archive and upload a build to just be told you forgot to change the build number in Info.plist. Automate it! Simply add a build phase to your project that either increments the build version by 1 or just use a timestamp:

Incremented number

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}"

Timestamp

buildNumber=$(date +%Y%m%d%H%M) /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"

Also make sure to check "For install builds only" to only run this step when archiving.

test

Note for Appcenter! If you have your build config on Appcenter configured to increment builds numbers you might run into issues if you use a custom build step like this.