Created
September 14, 2014 09:13
-
-
Save onmyway133/a6115f73d9e28ca4a195 to your computer and use it in GitHub Desktop.
how do I force Xcode to rebuild the Info.plist file in my project every time I build the project?
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
| // http://w3facility.info/question/how-do-i-force-xcode-to-rebuild-the-info-plist-file-in-my-project-every-time-i-build-the-project/#answer-18578076 | |
| # ---------------------------- IMPORTANT ---------------------------- | |
| # You must set GITHash to something like 'Set by build script' in the file | |
| # file '<Project Name>-Info.plist' in the 'Supporting Files' group | |
| # ------------------------------------------------------------------- | |
| # | |
| # Get the version number from the tag in git and the number of commits as the build number | |
| # | |
| appVersion=$(git describe --long | cut -f 1 -d "-") | |
| appBuild=$(git describe --long | cut -f 2 -d "-") | |
| gitHash=$(git describe --long | cut -f 3 -d "-") | |
| echo "From GIT Version = $appVersion Build = $appBuild" | |
| # | |
| # Set the version info in plist file | |
| # | |
| /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $appVersion" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" | |
| /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" | |
| /usr/libexec/PlistBuddy -c "Set :GITHash $gitHash" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" | |
| echo "Updated ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" | |
| FYI I also auto set the version and build on the About tab with the following code | |
| NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; | |
| NSString *appDisplayName = infoDictionary[@"CFBundleDisplayName"]; | |
| NSString *majorVersion = infoDictionary[@"CFBundleShortVersionString"]; | |
| NSString *minorVersion = infoDictionary[@"CFBundleVersion"]; | |
| self.appDescription.text = [NSString stringWithFormat:@"Dirty Dog Software\n%@\nVersion: %@(%@)", | |
| appDisplayName, majorVersion, minorVersion]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment