🐛

FlutterのアプリをiOSの実機で実行する時にNo supported devices connected.になってしまう場合の対処法

2021/08/09に公開

FlutterのアプリをiPhoneの実機で実行する時にNo supported devices connected.と表示されてしまい端末が認識されなくなってしまう場合がある。

様々な原因があるかとは思うが「昨日まで実行できていたのに何故...」となる時は大抵深夜にOSの自動バージョンアップがなされてしまっている場合である。

例えば14.6のOSが14.7にバージョンアップされた場合。下記のようにDeviceSupportディレクトリに対象のOSのdmgファイルが存在しないのが原因。

ls -la /Users/<YOUR USER NAME>/Library/Developer/Xcode/iOS\ DeviceSupport/
drwxrwxr-x  36 root  wheel  1152  8  9 10:29 .
drwxr-xr-x  10 root  wheel   320  1  9  2021 ..
drwxrwxr-x   4 root  wheel   128  1  9  2021 10.0
drwxrwxr-x   4 root  wheel   128  1  9  2021 10.1
drwxrwxr-x   4 root  wheel   128  1  9  2021 10.2
drwxrwxr-x   4 root  wheel   128  1  9  2021 10.3
drwxrwxr-x   4 root  wheel   128  1  9  2021 11.0
drwxrwxr-x   4 root  wheel   128  1  9  2021 11.1
drwxrwxr-x   4 root  wheel   128  1  9  2021 11.2
drwxrwxr-x   4 root  wheel   128  1  9  2021 11.3
drwxrwxr-x   4 root  wheel   128  1  9  2021 11.4
drwxrwxr-x   4 root  wheel   128  1  9  2021 12.0
.
.
.
drwxrwxr-x   4 root  wheel   128  1  9  2021 14.3
drwxr-xr-x   4 root  wheel   128  1  9  2021 14.4
drwxr-xr-x@  4 root  wheel   128  5 17 23:31 14.5
drwxr-xr-x   4 root  wheel   128  6 10 09:54 14.6 <- 14.6までしかない

対処法としてはここに14.7のDeviceSupportを追加してやれば良い。

実際のやり方はここに有志がDeviceSupportのzipを置いてくれているのでこれを先ほどの/Users/<YOUR USER NAME>/Library/Developer/Xcode/iOS\ DeviceSupportへ置いて展開するだけ。
https://github.com/iGhibli/iOS-DeviceSupport/tree/master/DeviceSupport

最新のOSバージョンとかへのアップデートだと結構あるのだけど、もし↑このリポジトリに欲しいDeviceSupportのファイルがない場合は自前で14.7のディレクトリを作成しひとつ前のバージョン(ここでは14.6)のディレクトリの中身をコピーしてくればOK。

$ sudo mkdir /Users/<YOUR USER NAME>/Library/Developer/Xcode/iOS\ DeviceSupport/14.7
$ sudo cp /Users/<YOUR USER NAME>/Library/Developer/Xcode/iOS\ DeviceSupport/14.6/* /Users/<YOUR USER NAME>/Library/Developer/Xcode/iOS\ DeviceSupport/14.7

Discussion