Skip to content

Instantly share code, notes, and snippets.

@matejkramny
Created March 10, 2013 02:08
Show Gist options
  • Save matejkramny/5126777 to your computer and use it in GitHub Desktop.
Save matejkramny/5126777 to your computer and use it in GitHub Desktop.
Increments the build number
#!/bin/bash
buildPlist="${PROJECT_DIR}/${INFOPLIST_FILE}"
# Get the existing buildVersion and buildNumber values from the buildPlist
versionString=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${buildPlist}")
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${buildPlist}")
buildDate=$(date "+%Y%m%d.%H%M%S")
# Increment the buildNumber
buildNumber=$(($buildNumber + 1))
# Set the version numbers in the buildPlist
/usr/libexec/PlistBuddy -c "Set :CFBuildDate $buildDate" "${buildPlist}"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${buildPlist}"
/usr/libexec/PlistBuddy -c "Set :CFBundleLongVersionString $versionString.$buildDate" "${buildPlist}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment