Skip to content

Instantly share code, notes, and snippets.

@luhui
Created December 27, 2014 02:13
Show Gist options
  • Select an option

  • Save luhui/0246a44ed53561e61b19 to your computer and use it in GitHub Desktop.

Select an option

Save luhui/0246a44ed53561e61b19 to your computer and use it in GitHub Desktop.
# 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