2013-06-06-git-version-sha-in-ios-apps.md 1.9 KB


title: git version sha in iOS apps author: Marcus Rohrmoser type: post date: 2013-06-06T15:45:54+00:00 url: /2013/06/git-version-sha-in-ios-apps/ yourls_shorturl:

categories:

  • en
    • development tags:
    • git
    • iOS
    • iPhone
    • plist
    • PlistBuddy
    • sha
    • version
    • XCode

there's tons of recipes out there how to do this – nevertheless I want to add another one:

xcode-git-sha-info-plist

  1. create a new build phase (here named „Git Sha -> Info.plist“)
  2. paste

    # write git version SHA into Info.plist
    #

    inspired by

    - http://kswizz.com/post/2686511526/git-xcode-versioning

    - http://stackoverflow.com/a/12658311

    cd "$PROJECT_DIR"

    say hello

    /usr/libexec/PlistBuddy -c "Set :CFBundleVersionGitSHA $(git rev-parse --short HEAD)" "$TARGET_BUILD_DIR/$INFOPLIST_PATH"

  3. add key CFBundleVersionGitSHA with placeholder text to your Info.plist

I went for this one because

  1. easy setup,
  2. no build/compiler settings changes,
  3. doesn't interfere with 'normal' versioning,
  4. simplest I've seen so far, no dependencies except git,
  5. explicit failure if e.g. git is missing.

Credits: