Created
January 5, 2011 05:13
-
-
Save koyachi/765964 to your computer and use it in GitHub Desktop.
ビルドオプション毎(アクティブな構成, ターゲット, architecture等)にバージョン情報を変える
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
XCodeの'グループとファイル'画面でターゲット選択、新規ビルドフェーズ(新規スクリプト)を追加 | |
スクリプトフェーズを最初に持ってくる('バンドルリソースをコピー'の前に持ってくる) | |
YourProject-Info.plistにVersionValueとVersionValueForDisplayキーを追加。VersionValueに\d+.\d+.\d+な文字列を入れる | |
スクリプトに以下を書く | |
VERSION=`cat ./YourProject-Info.plist | tr -d '\n\t' | perl -nle 'print ($_ =~ /^.*?<key>VersionValue<\/key><string>(\d+\.\d+\.\d+)<\/string>.*$/) ? $1 : ""'` | |
VERSION_FOR_DISPLAY=$VERSION-$CONFIGURATION-$ARCHS | |
/usr/libexec/PlistBuddy -c "Set :VersionValueForDisplay $VERSION_FOR_DISPLAY" ./YourProject-Info.plist | |
VersionValueForDisplayの値が0.0.2-Debug-i386みたいなかんじになるのでバージョン値表示したいとこでこの値を参照する | |
バージョンあげたいときにVersionValueに\d+.\d+.\d+な文字列を入れる | |
[参考] | |
http://stackoverflow.com/questions/877128/how-can-i-display-the-application-version-revision-in-my-applications-settings-b | |
http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW105 |
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
# build時に値更新 | |
declare -i BUILD_NO | |
BUILD_NO=`/usr/libexec/PlistBuddy -c "Print :BuildNo $VERSION" ./OjiichanKeitai-Info.plist` | |
BUILD_NO=$BUILD_NO+1 | |
BUILDINFO_FOR_DISPLAY=$CONFIGURATION-$CURRENT_ARCH-build$BUILD_NO | |
# buil_no更新 | |
/usr/libexec/PlistBuddy -c "Set :BuildNo $BUILD_NO" ./OjiichanKeitai-Info.plist | |
# Settings.bundle/Root.plist内の表示用バージョン値 | |
/usr/libexec/PlistBuddy -c "Set :PreferenceSpecifiers:2:DefaultValue $BUILDINFO_FOR_DISPLAY" ./Settings.bundle/Root.plist |
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
# DebugかつSimulatorでない == 開発者デバッグビルドなのでdist.plistのget-tastk-allowをチェックする | |
# 上記以外ならチェックを外す | |
if test $CONFIGURATION = "Debug" -a $CURRENT_ARCH != "i386"; then | |
/usr/libexec/PlistBuddy -c "Set :get-task-allow true" ./dist.plist | |
else | |
/usr/libexec/PlistBuddy -c "Set :get-task-allow false" ./dist.plist | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment