Skip to content

Instantly share code, notes, and snippets.

@mdales
Created May 6, 2012 15:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mdales/2622886 to your computer and use it in GitHub Desktop.
Save mdales/2622886 to your computer and use it in GitHub Desktop.
Updating Xcode project version number from git
# Assumes that you tag versions with the version number (e.g., "1.1") and then the build number is
# that plus the number of commits since the tag (e.g., "1.1.17")
echo "Updating version/build number from git..."
plist=${PROJECT_DIR}/${INFOPLIST_FILE}
# increment the build number (ie 115 to 116)
versionnum=`git describe | awk '{split($0,a,"-"); print a[1]}'`
buildnum=`git describe | awk '{split($0,a,"-"); print a[1] "." a[2]}'`
if [[ "${versionnum}" == "" ]]; then
echo "No version number from git"
exit 2
fi
if [[ "${buildnum}" == "" ]]; then
echo "No build number from git"
exit 2
fi
/usr/libexec/Plistbuddy -c "Set CFBundleShortVersionString $versionnum" "${plist}"
echo "Updated version number to $versionnum"
/usr/libexec/Plistbuddy -c "Set CFBundleVersion $buildnum" "${plist}"
echo "Updated build number to $buildnum"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment