Skip to content

Instantly share code, notes, and snippets.

@rsebbe
Created January 18, 2012 19:38
Show Gist options
  • Save rsebbe/1635096 to your computer and use it in GitHub Desktop.
Save rsebbe/1635096 to your computer and use it in GitHub Desktop.
Setting the CFBundleVersion in a build phase (Xcode >= 4.2). Voluntarily not using the info.plist prefix because of a dependency problem in Xcode build system.
#!/bin/sh
plbuddy="/usr/libexec/PlistBuddy"
toolsdir=$( dirname "${BASH_SOURCE[0]}" )
plist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
vers=`$toolsdir/make_build_version.sh`
vers="$vers"
major=`$plbuddy -c "Print :CFBundleShortVersionString" "$plist"`
major=(`echo $major | tr '.' ' '`)
major=${major[0]}
vers="$major.$vers"
echo "Setting CFBundleVersion to $vers"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $vers" "$plist"
/usr/bin/plutil -convert binary1 "$plist"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment