Skip to content

Instantly share code, notes, and snippets.

@mbehan
Created April 23, 2014 13:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbehan/11215484 to your computer and use it in GitHub Desktop.
Save mbehan/11215484 to your computer and use it in GitHub Desktop.
Add as a pre compile build phase in Xcode to auto increment your build number (bundle version). Format is revHash.user.number
last_commit=$(git rev-parse --short HEAD)$([[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && echo "*")
CFBundleVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNum=${CFBundleVersion##*.}
buildNum=$((buildNum + 1))
CFBundleVersion=$last_commit"."$USER"."buildNum
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" "$INFOPLIST_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment