Created
April 22, 2013 08:16
-
-
Save tokorom/5433218 to your computer and use it in GitHub Desktop.
Debugビルドのときもファイル経由でアプリにコミット日付を取り込めるようにしたスクリプト。
This file contains 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
last_commit_date.txt |
This file contains 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
lastCommitDate="" | |
configuration=`echo ${CONFIGURATION} | tr a-z A-Z` | |
if expr "${configuration}" : "^ADHOC" > /dev/null; then | |
# AdHoc | |
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${PROJECT_NAME}/App-Info.plist") | |
date=`git log -1 --format='%ci'` | |
buildNumber="${buildNumber} (ADHOC ${date})" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${PROJECT_NAME}/App-Info.plist" | |
elif expr "${configuration}" : "^DEBUG" > /dev/null; then | |
# Debug | |
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${PROJECT_NAME}/App-Info.plist") | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${PROJECT_NAME}/App-Info.plist" | |
date=`git log -1 --format='%ci'` | |
lastCommitDate=" (DEBUG ${date})" | |
else | |
# Distribution | |
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${PROJECT_NAME}/App-Info.plist") | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${PROJECT_NAME}/App-Info.plist" | |
fi | |
commitDateFileName="${PROJECT_DIR}/last_commit_date.txt" | |
echo "${lastCommitDate}" > "${commitDateFileName}" |
This file contains 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
NSError* error = nil; | |
NSString* path = [[NSBundle mainBundle] pathForResource:@"last_commit_date" ofType:@"txt"]; | |
NSString *addString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error]; | |
if (error) { | |
addString = @""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment