Skip to content

Instantly share code, notes, and snippets.

@tylerhall
Created January 24, 2011 08:26
Show Gist options
  • Save tylerhall/792971 to your computer and use it in GitHub Desktop.
Save tylerhall/792971 to your computer and use it in GitHub Desktop.
Inserts your most recent git commit hash into your app's Info.plist
<?PHP
$fn = "{$_ENV['BUILT_PRODUCTS_DIR']}/{$_ENV['WRAPPER_NAME']}/Contents/Info.plist";
$rev = trim(`git rev-parse HEAD`);
$plist = file_get_contents($fn);
$plist = preg_replace('/CFBundleVersion<\/key>.*?<string>(.*?)<\/string>/ms', "CFBundleVersion</key>\n\t<string>$rev</string>", $plist);
file_put_contents($fn, $plist);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment