I have found a few other posts that show how to add a script to increment the build number with a script:
Better way of incrementing build number?
Xcode proj
This is very similar to @Inafziger's answer, but a more concise set of code, with the added benefit that the check for "Release" is done with a checkbox in XCode rather than a runtime variable:
Follow these instructions twice, dragging one to the beginning and one to the end (one to run before build and one to run after build):
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Ensure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
# 7. Check the checkbox "Run script only when installing"
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"
See https://gist.github.com/sekati/3172554