Skip to content

Instantly share code, notes, and snippets.

@tokorom
Created April 22, 2013 08:16
Show Gist options
  • Save tokorom/5433218 to your computer and use it in GitHub Desktop.
Save tokorom/5433218 to your computer and use it in GitHub Desktop.
Debugビルドのときもファイル経由でアプリにコミット日付を取り込めるようにしたスクリプト。
last_commit_date.txt
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}"
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