-
Install custom build phase In Xcode go to the project settings:
Add build phase
=>Add run script
and paste`which git` show --abbrev-commit --pretty=oneline | head -1 | cut -d " " -f1 > revision
This should go before
Copy resource bundle
-
Add revision to Copy resource bundles
-
Load revision in Application by adding a Category on Application
- (NSString*)revision { static NSString* revisionNumber = nil; if (revisionNumber == nil) { NSString* revisionFile = [[NSBundle mainBundle] pathForResource:@"revision" ofType:nil]; if (revisionFile) { NSData* data = [NSData dataWithContentsOfFile:revisionFile]; NSString* fileContent = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; revisionNumber = [fileContent stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; } if (revisionNumber == nil) { revisionNumber = @"0000000"; } } return revisionNumber; }
Can be added as a property as well.
-
Load the revision from your code
[[UIApplication sharedApplication] revision]
Created
December 20, 2011 12:17
-
-
Save mk/1501382 to your computer and use it in GitHub Desktop.
HOWTO: Git generate and read revision for XCode/ObjC
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment