Skip to content

Instantly share code, notes, and snippets.

@slangley
Created September 17, 2015 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slangley/f09aaa11bba608478546 to your computer and use it in GitHub Desktop.
Save slangley/f09aaa11bba608478546 to your computer and use it in GitHub Desktop.
Add version info to an iOS App
#!/usr/bin/perl
use strict;
die "$0: Must be run from Xcode" unless $ENV{"BUILT_PRODUCTS_DIR"};
my $INFO = "$ENV{BUILT_PRODUCTS_DIR}/$ENV{WRAPPER_NAME}/Info.plist";
my $G_COMMIT = `git rev-parse --short HEAD`;
my $G_BRANCH = `git rev-parse --abbrev-ref HEAD`;
my $G_VERSION = `/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFO}"`;
my $G_BUILDNUM = `git rev-list HEAD --count`;
chomp($G_COMMIT);
chomp($G_BRANCH);
chomp($G_VERSION);
chomp($G_BUILDNUM);
my $REV = "$G_VERSION($G_BUILDNUM) $G_BRANCH $G_COMMIT";
print "REV: ^$REV^";
`/usr/libexec/PlistBuddy -c "Set :BuildDescription $REV" "$INFO"`;
`/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $G_BUILDNUM" "$INFO"`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment