Skip to content

Instantly share code, notes, and snippets.

@elmodos
Last active March 31, 2016 13:27
Show Gist options
  • Save elmodos/df3838db7782f9b1c122 to your computer and use it in GitHub Desktop.
Save elmodos/df3838db7782f9b1c122 to your computer and use it in GitHub Desktop.
Add this script to Build Phases of your target in Xcode to automatically set build number with SVN/Git revision number
# set build number only for release (Product|Archive)
if [ "$CONFIGURATION" == "Release" ]; then
# get GIT revision number
buildNumber=`git rev-list --count HEAD`
# if not git, then get SVN revision number
if [[ -z "$buildNumber" ]]; then
buildNumber=`svn info | grep "Revision" | awk '{print $2}'`
fi
# set default value if no rev number found
if [[ -z "$buildNumber" ]]; then buildNumber=1; fi
# write build number into project plit file
/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