Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.