Skip to content

Instantly share code, notes, and snippets.

@gauravkeshre
Created March 29, 2018 07:44
Show Gist options
  • Save gauravkeshre/658c58fbbf8303c95599eb269cc8a493 to your computer and use it in GitHub Desktop.
Save gauravkeshre/658c58fbbf8303c95599eb269cc8a493 to your computer and use it in GitHub Desktop.
Stores the SHA from last commit in the plist for beta app inspection purpose

Xcode Save SHA to Plist

What

Simple script to capture the last commit SHHA into plist. This script gets ignored if the code is not under git

How

Build Settings

  1. Select Target > Build Phases
  2. + > New Run Script Phase
  3. copy and paste this script in the script area.

Source

Analytics

GIT=$(which git)
GITOPTIONS="--pretty=oneline --abbrev-commit"
CUT=$(which cut)
SHA=`$GIT log -1 $GITOPTIONS | \$CUT -c1-7`
LOG=`$GIT log -1`
BRANCH=`$GIT rev-parse --abbrev-ref HEAD`
/usr/libexec/PlistBuddy -c "Set :GITCommitBranch $BRANCH" "${INFOPLIST_FILE}"
/usr/libexec/PlistBuddy -c "Set :GITCommitSHA $SHA" "${INFOPLIST_FILE}"
/usr/libexec/PlistBuddy -c "Set :GITCommitLog $LOG" "${INFOPLIST_FILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment