Skip to content

Instantly share code, notes, and snippets.

@rismay
Last active December 30, 2015 17:39
Show Gist options
  • Save rismay/7862740 to your computer and use it in GitHub Desktop.
Save rismay/7862740 to your computer and use it in GitHub Desktop.
This script bumps the version and build number every time you build and there has been a change to files in the build directory. The version and build numbers are the same. The Marketing Version is simply the build number / 100. The build number is displayed in Hex. To get this started: In your project settings put 0.00 in your version field and…
#!/bin/bash
if [ -n "$(find "$PROJECT_DIR" \! -path "*xcuserdata*" \! -path "*.git" -newer "$INFOPLIST_FILE")" ]; then
versionNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")
versionNumber=`echo $versionNumber +0.01|bc`
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $versionNumber" "$INFOPLIST_FILE"
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$((0x$buildNumber))
buildNumber=$(($buildNumber + 1))
buildNumber=$(printf "%X" $buildNumber)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment