Skip to content

Instantly share code, notes, and snippets.

@richy486
Created October 4, 2011 02:59
Show Gist options
  • Save richy486/1260804 to your computer and use it in GitHub Desktop.
Save richy486/1260804 to your computer and use it in GitHub Desktop.
updates your Xcode 4 info.plist with the current git tag as version and commit number
# updates your info.plist with the current git tag as version and commit number
# in that tag as build numer, then ammends the changed file to git
# run this after your normal commit but before you push
#
# this to be placed in the same directory as the xcode project file
# info.plist to be in the path [folder with projectfile]/[project name]/[project name]-Info.plist
# git tags to be in the form of v[number]
#
# Don't forget to do chmod +x ~/whatever/vTag.sh
#
# richy486@gmail.com
# twitter.com/richy486
fpp=`ls -d *.xcodeproj`
pn=${fpp%%.*}
echo $pn
cVersn=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" $pn/$pn-Info.plist`
cBuild=`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" $pn/$pn-Info.plist`
echo current version: $cVersn, current build: $cBuild
desc=`git describe --tags --long`
version=${desc#*v}
version=${version%%-*}
build=${desc#*-}
build=${build%%-*}
build="${version}.${build}"
echo new version: $version, new build: $build
/usr/libexec/PlistBuddy -c "Set CFBundleShortVersionString $version" $pn/$pn-Info.plist
/usr/libexec/PlistBuddy -c "Set CFBundleVersion $build" $pn/$pn-Info.plist
nVersn=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" $pn/$pn-Info.plist`
nBuild=`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" $pn/$pn-Info.plist`
echo changed version: $nVersn, changed build: $nBuild
git commit -a --amend -C HEAD
newDesc=`git describe --tags --long`
echo $newDesc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment