Skip to content

Instantly share code, notes, and snippets.

@xor-gate
Forked from qvivo-tom/vTag.sh
Created August 7, 2016 21:29
Show Gist options
  • Select an option

  • Save xor-gate/ad7de8888d9920e881ba69122f0826cf to your computer and use it in GitHub Desktop.

Select an option

Save xor-gate/ad7de8888d9920e881ba69122f0826cf 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
#
# 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%%-*}
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment