Skip to content

Instantly share code, notes, and snippets.

@uasi
Created February 17, 2014 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uasi/9046447 to your computer and use it in GitHub Desktop.
Save uasi/9046447 to your computer and use it in GitHub Desktop.
Xcode build phase that writes git revision to Info.plist in built product
GIT_REVISION=$(git rev-parse --short HEAD 2> /dev/null)
if [ $? != 0 ]; then
GIT_REVISION="(not in git repo)"
elif [ -n "$(git status --porcelain)" ]; then
GIT_REVISION="${GIT_REVISION}+dirty"
fi
PLIST_PATH="${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/Info.plist"
/usr/libexec/PlistBuddy -c "Set :GitRevision ${GIT_REVISION}" "${PLIST_PATH}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment