Skip to content

Instantly share code, notes, and snippets.

@lifecube
Created August 22, 2015 07:10
Show Gist options
  • Save lifecube/c4041ca1fa65c6e8f53e to your computer and use it in GitHub Desktop.
Save lifecube/c4041ca1fa65c6e8f53e to your computer and use it in GitHub Desktop.
Auto update xcode project build number and build version using the current timestamp
# xcode-build-timestamp-version.sh
# @desc Auto-update the build number and build version every time the project is run using the current timestamp.
# @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. Check the checkbox "Run script only when installing"
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(date +"%Y%m%d%H%M%S")
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"
buildVersion=$(date +"%Y.%m.%d")
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $buildVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment