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.

Revisions

  1. lifecube created this gist Aug 22, 2015.
    15 changes: 15 additions & 0 deletions xcode-build-timestamp-version.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    # 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}"