Skip to content

Instantly share code, notes, and snippets.

@ethanliu
Created June 1, 2016 10:45
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 ethanliu/7b8ca0ef571bfbbd217014834497d421 to your computer and use it in GitHub Desktop.
Save ethanliu/7b8ca0ef571bfbbd217014834497d421 to your computer and use it in GitHub Desktop.
Xcode Build Script - Use git HEAD counts for CFBundleVersion without dirty the repo
git=`sh /etc/profile; which git`
appBuild=`"$git" rev-list HEAD --count`
infoPath="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
#infoPath="${PROJECT_DIR}"/"${INFOPLIST_FILE}"
if [ $CONFIGURATION = "Debug" ]; then
branchName=`"$git" rev-parse --abbrev-ref HEAD`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild-$branchName" "$infoPath"
else
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "$infoPath"
fi
echo "Updated ($appBuild) $infoPath"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment