Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

CFBundleVersionをReleaseビルドの時だけ更新

More than 3 years have passed since last update.

タイトルの通り。
よくアーカイブする時にわすれるので。
会社でも調べたけど、家でもう一回調べたので忘れないように備忘録。

Run Scriptに追加

下の方だとビルド終わってから更新になって意味がないので、私はTarget Dependenciesの直後に追加してます
Edit SchemeのArchiveのPre-actionsでやろうとしたけど上手くできなかったのでBuild Phasesに追加してます

if [[ ${CONFIGURATION} == "Release" ]]; then
    buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PRODUCT_SETTINGS_PATH}")
    buildNumber=$(($buildNumber + 1))
    /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PRODUCT_SETTINGS_PATH}"
    echo "[UpdateBuildNumber Release] CFBundleVersion Increment ${buildNumber}"
else
    buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PRODUCT_SETTINGS_PATH}")
    echo "[UpdateBuildNumber Debug] CFBundleVersion Not Increment ${buildNumber}"
fi

echoはなくてもOK
ビルドログで確認できるように出力しているだけです

Debug

Debug.png

Release

Release.png

MTattin
iOS Developer / Serverも時々
https://faboll.tattin.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away