10
6

More than 1 year has passed since last update.

ios実機デバッグ時に、後からデバイスを追加する方法

Last updated at Posted at 2020-09-01

タイトルについて1時間ほどハマったのでメモ。

背景

iPhoneで実機デバッグをしていたが、複数端末でデバッグする必要が出てきたので、iPadでも実機デバッグをしたかった。

環境

Flutter 1.20.2
Xcode 11.6

XcodeはAutomatically manage signingをオンにした状態

Flutter以外でも参考にはなると思います。

手順

appleのdeveloperコンソールでデバイスを追加

デバイス一覧ページよりデバイスを追加します。
Device ID (UDID)の取得方法はappleのサポートの記事が参考になります。

過去のProvisioning Profileを削除

ここがハマりポイントです。
XcodeはSigningを自動でしてくれる、Automatically manage signingという機能があります。これを設定すると自分でプロビジョニングプロファイル等を設定が自動化されるので大変便利です。
今回も自動でdeviceの追加が行われると思ったのですが、残念ながらflutter runを行った結果下のようになりました。

❯ flutter run
Launching lib/main.dart on iPad in debug mode...

Automatically signing iOS for device deployment using specified development team in Xcode project: XXXXXXXXX
Running Xcode build...

 └─Compiling, linking and signing...                        22.7s
Xcode build done.                                           55.0s
════════════════════════════════════════════════════════════════════════════════
No Provisioning Profile was found for your project's Bundle Identifier or your
device. You can create a new Provisioning Profile for your project in Xcode for
your team by:
  1- Open the Flutter project's Xcode target with
       open ios/Runner.xcworkspace
  2- Select the 'Runner' project in the navigator then the 'Runner' target
     in the project settings
  3- Make sure a 'Development Team' is selected.
     - For Xcode 10, look under General > Signing > Team.
     - For Xcode 11 and newer, look under Signing & Capabilities > Team.
     You may need to:
         - Log in with your Apple ID in Xcode first
         - Ensure you have a valid unique Bundle ID
         - Register your device with your Apple Developer Account
         - Let Xcode automatically provision a profile for your app
  4- Build or run your project again

It's also possible that a previously installed app with the same Bundle
Identifier was signed with a different certificate.

For more information, please visit:
  https://flutter.dev/setup/#deploy-to-ios-devices

Or run on an iOS simulator without code signing
════════════════════════════════════════════════════════════════════════════════
2020-09-01 15:39:49.021 ios-deploy[39025:240546] [ !! ] Error 0xe8008015: A valid provisioning profile for this executable was not found. AMDeviceSecureInstallApplication(0, device, url, options, install_callback, 0)
Could not run build/ios/iphoneos/Runner.app on XXXXXXXXX-XXXXXXXXX.
Try launching Xcode and selecting "Product > Run" to fix the problem:
  open ios/Runner.xcworkspace

Installing and launching...                                        25.8s
Error launching application on iPad.

原因としては、Automatically manage signingによって作成されたプロビジョニングプロファイルがデバイスを追加する前のままだったことです。したがって、以前のプロビジョニングプロファイルを一旦削除する必要があります。プロビジョニングプロファイルは
~/Library/MobileDevice/Provisioning Profilesに存在するので、削除します。

> cd ~/Library/MobileDevice/Provisioning\ Profiles
> rm xxxxx-xxx-xxxx-xxxxxx.mobileprovision

これで自動でXcodeが自動で新しいプロビジョニングプロファイルを作成し、deviceの追加が無事完了します。

10
6
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
10
6