git version sha in iOS apps

Thu, 06. Jun 2013

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:

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

    # write git version SHA into Info.plist
    # inspired by
    # -
    # -
    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.