DEV Community

loading...

Set Xcode build numbers to incremented or timestamps

andreasbergstrom profile image Andreas Bergström ・1 min read

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}"
Enter fullscreen mode Exit fullscreen mode

Timestamp

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

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.

Discussion (0)

pic
Editor guide