Created
February 9, 2016 11:35
-
-
Save rraallvv/f19b724b63dbe150e86f to your computer and use it in GitHub Desktop.
Xcode build phase script for auto-versioning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Xcode auto-versioning script for Subversion | |
| # by Axel Andersson, modified by Daniel Jalkut to add | |
| # "--revision HEAD" to the svn info line, which allows | |
| # the latest revision to always be used. | |
| # See http://www.red-sweater.com/blog/23/automatic-build-sub-versioning-in-xcode#finalscript | |
| use strict; | |
| die "$0: Must be run from Xcode" unless $ENV{"BUILT_PRODUCTS_DIR"}; | |
| # Get the git commit and use it to set the CFBundleVersion value | |
| my $REV = `cd $ENV{SRCROOT}; git log -1 --pretty=%h`; | |
| chomp($REV); | |
| my $INFO = "$ENV{BUILT_PRODUCTS_DIR}/$ENV{WRAPPER_NAME}/Contents/Info.plist"; | |
| my $version = $REV; | |
| open(FH, "$INFO") or die "$0: $INFO: $!"; | |
| my $info = join("", <FH>); | |
| close(FH); | |
| $info =~ s/([\t ]+<key>CFBundleVersion<\/key>\n[\t ]+<string>).*?(<\/string>)/$1$version$2/; | |
| open(FH, ">$INFO") or die "$0: $INFO: $!"; | |
| print FH $info; | |
| close(FH); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment