1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Flutter】急にiosで実機デバッグが出来なくなった時に試してほしいこと

Posted at

ある時、急にiosで実機デバッグができなくなり、大変困ったので、解決内容記事にしたいと思います。
この方法で解決するとは限りませんが、一度試してほしいです。

エラーの現象

VScodeでiPhoneを繋ぎ、デバッグを実行すると突然下記のようなエラーが出ました。

Could not build the precompiled application for the device.
════════════════════════════════════════════════════════════════════════════════
Building a deployable iOS app requires a selected Development Team with a 
Provisioning Profile. Please ensure that a Development Team is selected 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 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

For more information, please visit:
  https://flutter.dev/docs/get-started/install/macos#deploy-to-ios-devices

Or run on an iOS simulator without code signing
════════════════════════════════════════════════════════════════════════════════

Error launching application on iPhone11.

こういうエラーを調べると、プロビジョニングファイルを作ったり、XcodeでSingingしたりする手順を紹介している記事が出てきます。
上記はすでに対応済みで(今まで実機でデバッグできていたので当たり前と言えば当たり前)、Xcodeを見てもSiginingには問題はありません。

デバッグ開始後のログには以下のようなログになっている。

Launching lib/main.dart on iPhone11 in debug mode...
main.dart:1
Signing iOS app for device deployment using developer identity: "Apple Development: xxxxxx@example.com (xxxxxxx)"
Xcode build done.                                           33.5s
Failed to build iOS app
Error output from Xcode build:

エラーの原因

こんなエラーに困っている方は一度iPhoneを接続したままで、XCodeを開いていみてください
そして、Product > destinationを選択してください
すると、こうなっている可能性があります。

image.png

エラーの直し方

Failed to prepare the device for development.でググると、解決策がたくさん出てきます。

再起動

まず、手軽に試せる方法としては、iPhoneとPCの再起動です。
もし再起動でも直らなかったら次の手順を試してみてください
(私の場合、再起動では直りませんでした)

iPhoneのOS、PCのOS、XCodeのバージョンを最新にする

面倒ですが、バージョンを更新してください。
ただし、全部やる必要はなさそうです。
私の場合は、XCodeを最新にするだけで直りました。
なので、まずXCodeを最新にして直らなかったら、iPhoneかmacのOSのバージョンを上げるのが良さそうです。

XCodeの更新は下記の記事のようにいくつか方法があります。

個人的にはXCodesで管理するのが楽だと思うので、[導入の参考記事](https://sunny10side.com/install-xcodes-to-manage-xcode-versions/)を貼っておきます。

Appleの開発者向けページからダウンロードする場合はSafariで実施した方がいいという記事だったか、ツイートだったかをみたことがありますので、Safariで実施した方が良さげです。

AppStoreからやるのはお勧めしません。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?