Created
December 27, 2014 02:13
-
-
Save luhui/0246a44ed53561e61b19 to your computer and use it in GitHub Desktop.
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
| # This script retrieves the git count to build number. | |
| # Instructions: | |
| # Add this file to your project bundle or target. | |
| # Go to Project settings > target > Build Phases > Run Script. | |
| # Add Shell /bin/sh and a value with the bundle path to this script | |
| INFOPLISTPATH="${TARGET_BUILD_DIR}/${EXECUTABLE_NAME}.app/Info.plist" | |
| # Location of PlistBuddy | |
| PLISTBUDDY="/usr/libexec/PlistBuddy" | |
| # Get the current git count | |
| GITCOUNT=$(git --git-dir="${PROJECT_DIR}/.git" --work-tree="${PROJECT_DIR}" rev-list HEAD --count) | |
| echo "GIT COUNT = ${GITCOUNT}" | |
| echo "INFOPLISTPATH = ${INFOPLISTPATH}" | |
| # Set the Git count in the info plist for reference | |
| $PLISTBUDDY -c "Set :CFBundleVersion $GITCOUNT" "${INFOPLISTPATH}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment