git version sha in iOS apps

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
    1
    2
    3
    4
    5
    6
    7
    8
    
    # 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:

Flattr this!

Post a Comment

Your email is never published nor shared. Required fields are marked *