# 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}"