Skip to content

Instantly share code, notes, and snippets.

@madninja
Created February 26, 2011 19:41
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madninja/845548 to your computer and use it in GitHub Desktop.
Save madninja/845548 to your computer and use it in GitHub Desktop.
Inject git version info into Info.plist and iOS settings
#!/bin/bash
cd $PROJECT_DIR
BUILD_VERSION=`/usr/local/bin/git rev-parse --short HEAD`
cd "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app"
RELEASE_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" Info.plist)
/usr/libexec/PlistBuddy -c "Set CFBundleVersion $BUILD_VERSION" Info.plist
/usr/libexec/PlistBuddy -c "Set :PreferenceSpecifiers:1:DefaultValue $RELEASE_VERSION ($BUILD_VERSION)" Settings.bundle/Root.plist
@markph0204
Copy link

Line 4, wrap the path variables in double quotes so it properly handles spaces in product name, etc.

cd "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app"

@madninja
Copy link
Author

madninja commented Oct 8, 2011

Thanks Mark!

@markph0204
Copy link

Your welcome...
Found two more things, lines 5 & 6:

RELEASE_VERSION=$(/usr/libexec/PListBuddy -c "Print CFBundleShortVersionString" Info.plist)
/usr/libexec/PListBuddy -c "Set CFBundleVersion $BUILD_VERSION" Info.plist

Lowercase the "L" in PListBuddy such that:

RELEASE_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" Info.plist)
/usr/libexec/PlistBuddy -c "Set CFBundleVersion $BUILD_VERSION" Info.plist

@madninja
Copy link
Author

Done.. thanks again.. I use this daily and am glad someone else finds it useful

@markph0204
Copy link

markph0204 commented Oct 26, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment