CFBundleVersionとCFBundleShortVersionString Mismatch の自動対応方法
- App Extension(画像付きPush や WatchKit Extension)を使ってるアプリで、申請する際に出てくる、下記の警告の自動対応したいから書いた記事
警告内容
CFBundleVersion Mismatch
CFBundleShortVersionString Mismatch
Sync Bundle Version
- Xcodeのrun scriptで、iOSアプリのビルド番号を手軽に自動採番する を参考にXcode Run Script を追加する
- 下記の部分を書き換える
- 親アプリのInfo.plist
path/to/Info.plist - ExtensionのInfo.plist
path/to/ExtensionInfo.plist - Run Scriptは 揃えたい対象のExtensionに書く事!
- Project > Target > Extension > Build Phases
SyncBundleVersion
# !/bin/bash
build_number=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "path/to/Info.plist")
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $build_number" "path/to/ExtensionInfo.plist"
build_number=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "path/to/Info.plist")
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $build_number" "path/to/ExtensionInfo.plist"
実行内容
- 親アプリのCFBundleVersionを取得(path/to/Info.plist)
- ExtensionのCFBundleVersionを上書き(path/to/ExtensionInfo.plist)
- 親アプリのCFBundleShortVersionStringを取得(path/to/Info.plist)
- ExtensionのCFBundleShortVersionStringを上書き(path/to/ExtensionInfo.plist)
終わりに
- 単純にExtensionのInfo.plistのBundle versionに親アプリの環境変数を入れられたら解決なのだけども、標準だと見つからなかった
- 他の方法があれば教えてください