Skip to content

Instantly share code, notes, and snippets.

@parrots
Created April 9, 2015 01:28
Show Gist options
  • Save parrots/d37f390d06114a4167c6 to your computer and use it in GitHub Desktop.
Save parrots/d37f390d06114a4167c6 to your computer and use it in GitHub Desktop.
Watchkit versioning build phase
git=`sh /etc/profile; which git`
branch_name=`$git symbolic-ref HEAD | sed -e 's,.*/\\(.*\\),\\1,'`
git_count=`$git rev-list $branch_name |wc -l | sed 's/^ *//;s/ *$//'`
simple_branch_name=`$git rev-parse --abbrev-ref HEAD`
build_number="$git_count"
if [ $CONFIGURATION != "Release" ]; then
build_number+="-$simple_branch_name"
fi
plist="${SRCROOT}/WatchKit App/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $build_number" "$plist"
@parrots
Copy link
Author

parrots commented Apr 9, 2015

Add this as a build phase one your parent app. Update the plist variable to point to your watchkit app's info.plist.

Note this will modify the info.plist for the watchkit app every build, might want to git update-index --assume-unchanged "Watchkit App/Info.plist" that bad boy.

This reuses the numbering strategy found in my versioning post

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