Skip to content

Instantly share code, notes, and snippets.

@TBonnin
Forked from mdales/gist:2622886
Created May 29, 2012 12:46
Show Gist options
  • Save TBonnin/2828203 to your computer and use it in GitHub Desktop.
Save TBonnin/2828203 to your computer and use it in GitHub Desktop.
Updating Xcode project version number from git
# Use git describe as build number
echo "Updating version/build number from git..."
plist=${PROJECT_DIR}/${INFOPLIST_FILE}
# Get build/version number
versionnum=`git describe --tags | awk '{split($0,a,"-"); print a[1]}'`
buildnum=`git describe --tags`
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