Last active
August 29, 2015 14:19
-
-
Save Galarius/ef2a8792dd37fb6f41b9 to your computer and use it in GitHub Desktop.
Build app version using the latest hg commit hash and datetime.
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
| # Custom iOS app version | |
| # @usage | |
| # 1. Select: your Target in Xcode | |
| # 2. Select: Build Phases Tab | |
| # 3. Select: Add Build Phase -> Add Run Script | |
| # 4. Paste code below in to new "Run Script" section | |
| # 5. Drag the "Run Script" below "Link Binaries With Libraries" | |
| # 6. Insure that LastCommitHash and LastBuildDate are in your app plist file. | |
| # 7. Somewhere in your obj-c code paste: | |
| # + (NSString *)appVersionCommitHash { | |
| # NSString *lastCommitHash = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"LastCommitHash"]; | |
| # return lastCommitHash; } | |
| # + (NSString *)appVersionDate { | |
| # NSString *lastBuildDate = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"LastBuildDate"]; | |
| # return lastBuildDate; } | |
| # save the latest hg commit hash | |
| # in case hg has alias in .bash_profile | |
| if [ -f ~/.bash_profile ]; | |
| then | |
| source ~/.bash_profile | |
| fi | |
| LAST_COMMIT_HASH=$(hg id -i) | |
| /usr/libexec/PlistBuddy -c "Set :LastCommitHash $LAST_COMMIT_HASH" "$INFOPLIST_FILE" | |
| # save the latest build date | |
| NOW=$(date +'%y%m%d.%H%M') | |
| /usr/libexec/PlistBuddy -c "Set :LastBuildDate $NOW" "$INFOPLIST_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment