Last active
September 15, 2018 08:34
-
-
Save rodydavis/14a408e130a0968a1173ce2eead7ca4d to your computer and use it in GitHub Desktop.
Auto Increment Build and Version Numbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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
Actually, doesn't work for me, Xcode 9.3.1.
I did all the steps, but the build number remains the same after building.