👻

Flutter iOS実機での開発で "Lost connection to device" が出る場合の対処

2020/12/17に公開

Flutter でiOSの実機での開発起動(flutter run)しようとすると、アプリが起動した直後に接続が切れてしまうことがあります。以下のようなエラーが出ます。

An Observatory debugger and profiler on My iPhone is available at: http://127.0.0.1:1025/
For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
Service protocol connection 
Lost connection to device.
DevFS: Deleting filesystem on the device (file:///private/var/mobile/Containers/Data/Application/.../)
Sending to VM service: _deleteDevFS({fsName: myapp})
Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not completed

接続が切れると、ホットリロードができなくなってしまいます。


これは iOS の開発に使っている libusbmuxd というツールのバグのようです。

このバグが修正されるまでは、特定のバージョンの libusbmuxd を使う必要があり、Flutterの Issue #35102 のコメント で以下のようなワークアラウンドが紹介されていました。

brew uninstall --ignore-dependencies usbmuxd libimobiledevice ideviceinstaller
brew tap flutter/flutter https://flutter-mirrors.googlesource.com/homebrew-flutter
brew install --HEAD usbmuxd-flutter libimobiledevice-flutter ideviceinstaller-flutter

上記のような感じで usbmuxd libimobiledevice ideviceinstaller の3つを入れ直すと動くようになると思います。

この記事はQiitaの記事をエクスポートしたものです

Discussion