LoginSignup
2
1

Apple Watch 公式チュートリアルでビルドが通らないとき

Last updated at Posted at 2023-10-18

Appleの公式SwiftUI Tutorialsは品質が高くて俄然やる気が出ます。
ただし今回はビルドができない問題に引っかかったので、その対処法を紹介します。

課題

上記サンプルアプリの完成版プロジェクトを開いて署名し実機テストしようとすると以下のエラーメッセージが出た。

Error Message

WatchKit App doesn't contain any WatchKit Extensions whose WKAppBundleIdentifier matches "com.example.apple-samplecode.LandmarksXXXXXXXXXX.watchkitapp". Verify that the value of WKAppBundleIdentifier in your WatchKit Extension's Info.plist matches the value of CFBundleIdentifier in your WatchKit App's Info.plist.

WatchKit ExtensionsWKAppBundleIdentifier
WatchKit AppCFBundleIdentifierが一致していないことが問題のよう。

原因

各TargetのBundle Identifierは以下の通り。
Screenshot 2023-10-18 at 22.33.48.png
*Bundle Identifierは上記画像のように各TargetのSining &Capabilitiesから確認可能。

  1. Landmarks (iOS App): com.example.apple-samplecode.Landmarks${SAMPLE_CODE_DISAMBIGUATOR}
  2. WatchLandmarks(WatchOS APP): com.example.apple-samplecode.Landmarks${SAMPLE_CODE_DISAMBIGUATOR}.watchkitapp
  3. WatchLandmarks Extension: com.example.apple-samplecode.Landmarks${SAMPLE_CODE_DISAMBIGUATOR}.watchkitapp.watchkitextension

唐突に出てくる${SAMPLE_CODE_DISAMBIGUATOR}って誰だよ。Screenshot 2023-10-18 at 22.42.39.png

(自分の理解では)AppleのTutorialのような公開プロジェクトは配布時にBundle Identifierに初期値を与えるとみんなで衝突しちゃうから、それを回避するために、Development TeamのID?を加えてユニークな値になるようにしている。

なのに、下記画像のようにInfoタブから確認できるプロパティリストの方ではBundle IdentifierにDevelopment Teamに関連する値が追加されていない。
Screenshot 2023-10-18 at 22.49.11.png
Screenshot 2023-10-18 at 22.56.30.png

解決法

Screenshot 2023-10-18 at 22.55.22.png

Screenshot 2023-10-18 at 22.51.39.png

  1. WatchLandmarks(WatchOS APP)のWKCompanionAppBundleIdentifiercom.example.apple-samplecode.Landmarks${DEVELOPMENT_TEAM}と設定。
  2. WatchLandmarks Extensionの NSExtension > NSExtensionAttributes > WKAppBundleIdentifiercom.example.apple-samplecode.Landmarks${DEVELOPMENT_TEAM}.watchkitappと設定。

これでいける。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1