Skip to content

Instantly share code, notes, and snippets.

@getaclue00
Forked from rodydavis/AutoIncrementBuilds.sh
Created June 23, 2018 17:26
Show Gist options
  • Select an option

  • Save getaclue00/bb1cbbfdd12bb1b4b41a890f0cc92ffe to your computer and use it in GitHub Desktop.

Select an option

Save getaclue00/bb1cbbfdd12bb1b4b41a890f0cc92ffe to your computer and use it in GitHub Desktop.
Auto Increment Build and Version Numbers
#Works with Xcode 9 (Confirmed)
#1. Go to "Edit Schemes"
#2. Go to "Build"
#3. Go to "Pre-Actions"
#4. Select YOUR app in "Provide Build Settings from:"
#5. Paste Below Script in Box
#6. Build Project
#Build Number ++
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$PRODUCT_SETTINGS_PATH")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$PRODUCT_SETTINGS_PATH"
#Version Number ++
VERSIONNUM=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$PRODUCT_SETTINGS_PATH")
NEWSUBVERSION=`echo $VERSIONNUM | awk -F "." '{print $3}'`
NEWSUBVERSION=$(($NEWSUBVERSION + 1))
NEWVERSIONSTRING=`echo $VERSIONNUM | awk -F "." '{print $1 "." $2 ".'$NEWSUBVERSION'" }'`
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $NEWVERSIONSTRING" "$PRODUCT_SETTINGS_PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment