I too have automated setting my version numbers. I created a Run Script Build Phase. The key is to update the target build directory copy of the Info.plist not build directory one. You also need to have your run script after the copy bundle phase. It ok to edit the bundle file directly because is before code signing. You don’t want to generate the file thats reinventing the wheel.
Created
September 11, 2014 02:25
-
-
Save paulyoung/5b74e7948bfbe3ddf632 to your computer and use it in GitHub Desktop.
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
// 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]; |
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
# ---------------------------- 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}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment