Xcode auto-increment build on archive

Simple script to bump the build number of my Xcode project on each Archive. The version number I am leaving as a manual change for the moment, but each time I release a build to testers, I want the build to change and a commit message for the change. In Xcode from the menu go to Product -> Scheme -> Edit Scheme EditSchemeMenu On the side, expand the Arhive build and select Pre-actions. Here we will edit the pre-action script to increment the build number. Choose to provide the build settings from your main app target and in the script pane add:

BUILD_NUM=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
VERSION_NUM=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")

BUILD_NUM=$(($BUILD_NUM + 1))

/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUM" "${PROJECT_DIR}/${INFOPLIST_FILE}"

cd "${SRCROOT}";/usr/bin/git add "${PROJECT_DIR}/${INFOPLIST_FILE}"
cd "${SRCROOT}";/usr/bin/git commit -m "Post archive bumped build number to ${BUILD_NUM} for version ${VERSION_NUM}"
cd "${SRCROOT}";/usr/bin/git tag -f -a "v${VERSION_NUM}b${BUILD_NUM}" -m "Version ${VERSION_NUM}, Buidl ${BUILD_NUM}"

The Run Script pane will look like this afterwards: IncrementScriptEditing I also have another configuration for App Store release which you could then apply this same script except change the CFBundleShortVersionString to increment the version number