Skip to content

Instantly share code, notes, and snippets.

@jeremygibbs
Created July 2, 2014 02:40
Show Gist options
  • Save jeremygibbs/69dff746c372176215d7 to your computer and use it in GitHub Desktop.
Save jeremygibbs/69dff746c372176215d7 to your computer and use it in GitHub Desktop.
Shell script for the build phase that auto-increments an Xcode project's build number.
# Auto Increment Version Script
buildPlist=$INFOPLIST_FILE
echo $buildPlist
CFSVString=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$buildPlist")
CFBundleVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$buildPlist")
BUILD_NR=${CFBundleVersion##*.}
BUILD_NR=$(($BUILD_NR + 1))
LEN=$(echo ${#CFSVString})
if [ $LEN -eq 3 ]; then
CFBundleVersion=$CFSVString".0."$BUILD_NR
else
CFBundleVersion=$CFSVString"."$BUILD_NR
fi
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" "$buildPlist"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment