XcodeでiPhoneの実機を使う方法

エンジニア

デフォルトではiPhone14 Proが選択されています。

クリックすると自分の持っているiPhoneが表示されます。これをクリックして再生ボタンを押すと

「The run destination わっしょい is not valid for Running the scheme ‘ARtest’.」

「To use わっしょい for development, enable Developer Mode in Settings → Privacy & Security.」と警告が出ます。これはiPhone側でデベロッパーモードの設定ができてないためです。

iPhoneの設定を開き、「プライバシーとセキュリティ

デベロッパーモード」を開き

デベロッパーモードを「オン」にします。

Xcodeに戻り再度ビルドするとまた別の警告が出ます。「The run destination わっしょい is not valid for Running the scheme ‘ARtest’.」「Failed to prepare the device for development. This operation can fail if the version of the OS on the device is incompatible with the installed version of Xcode. You may also need to restart your Mac and device in order to correctly detect compatibility.」

これはXcodeのアップデートが残ってたりOSアップデートが残っている時に出ます。AppStoreからXcodeをアップデートしましょう。その後ビルドすると今度はこれが出ます。

「The operation couldn’t be completed. Unable to launch **** because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user.」

iPhoneにも警告が出ています。「このiPhone でデベロッパ”****”のAppを使用することは現在のデバイス管理設定では許可されていません。これらのAppの使用は、“設定”で許可することができます。」

iPhoneでさらに設定が必要です。

「設定」→「一般」→「VPNとデバイス管理」

「デベロッパAPP」を選択。

「…を信頼」をクリック。

これで再度ビルドをするとうまくいきます。