Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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