Xcode Run Script to Auto-increment Build Number

Auto-incrementing build number.

  • 0. Target -> Build Phases -> Target Dependencies. Click on “Add target dependencies here” area (Xcode bug to get step 1 not greyed out)
  • 1. Editor -> Add Build Phase -> Add Run Script Build Phase
  • 2. Paste this code
  • 3. Change CFBundleDisplayName prefix. eg. Ped
  • 4. Add Row Bundle display name (aka CFBundleDisplayName) to Info.plist
# 0. Target -> Build Phases -> Target Dependencies. Click on "Add target dependencies here" area (Xcode bug to get step 1 not greyed out)
# 1. Editor -> Add Build Phase -> Add Run Script Build Phase
# 2. Paste this code
# 3. Change CFBundleDisplayName prefix. eg. Pedometer
# 4. Add Row "Bundle display name" (aka CFBundleDisplayName) to Info.plist

#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName Ped $buildNumber" "$INFOPLIST_FILE"

One Reply to “Xcode Run Script to Auto-increment Build Number”

Comments are closed.