Skip to content

Instantly share code, notes, and snippets.

@edwardmp
Last active August 29, 2015 14:16
Show Gist options
  • Save edwardmp/86f912c98a3c96411714 to your computer and use it in GitHub Desktop.
Save edwardmp/86f912c98a3c96411714 to your computer and use it in GitHub Desktop.
Xcode 6 automatic build number updating based on amount of Git commits
buildPlist="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
PlistBuddy="/usr/libexec/PlistBuddy"
git=`sh /etc/profile; which git`
CFBundleVersion=`"$git" rev-list --all | wc -l`
$PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" "$buildPlist"
#$PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" "$INFOPLIST_FILE"
$PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" "${DWARF_DSYM_FOLDER_PATH}/${WRAPPER_NAME}.dSYM/Contents/Info.plist"
@edwardmp
Copy link
Author

Add this as a run script, after the copy bundle resources phase. Click the checkmark next to "run script only when installing", this will make sure the build number is only incremented when the scheme is set to release or an archive export is done. It does not change your local Info.plist file (this is the commented out line), so it does not dirty your git commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment