Last active
October 4, 2015 13:28
-
-
Save digitalpardoe/2644629 to your computer and use it in GitHub Desktop.
Automatic Build Number In Xcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Automatically sets the build number for a target in Xcode based | |
# on either the Subversion revision or Git hash depending on the | |
# version control system being used | |
# | |
# Simply add this script as a 'Run Script' build phase for any | |
# target in your project | |
# | |
git status | |
if [ "$?" -eq "0" ] | |
then | |
git svn info | |
if [ "$?" -eq "0" ] | |
then | |
buildNumber=$(git svn info | grep Revision | awk '{print $2}') | |
else | |
buildNumber=$(git rev-parse HEAD | cut -c -10) | |
fi | |
elif [ -d ".svn" ] | |
then | |
buildNumber=$(svn info | grep Revision | awk '{print $2}') | |
else | |
buildNumber=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" Source/Application-Info.plist) | |
fi | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" Source/Application-Info.plist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment