Flutter開発環境構築でのトラブル

Flutter開発で、iPhone実機テストを行おうと思って、$ flutter doctorで環境を確認したが、以下のエラーが出た。

[!] iOS toolchain - develop for iOS devices (Xcode 9.2)
✗ libimobiledevice and ideviceinstaller are not installed. To install, run:
brew install --HEAD libimobiledevice
brew install ideviceinstaller
! CocoaPods out of date (1.5.0 is recommended).
CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
For more info, see https://flutter.io/platform-plugins
To upgrade:
brew upgrade cocoapods
pod setup

エラーメッセージどおり$ brew install --HEAD libimobiledeviceを試すが、以下のエラーが出る。

==> Installing dependencies for libimobiledevice: libplist
==> Installing libimobiledevice dependency: libplist
==> Downloading https://homebrew.bintray.com/bottles/libplist-2.0.0_1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libplist-2.0.0_1.sierra.bottle.tar.gz
🍺 /usr/local/Cellar/libplist/2.0.0_1: 29 files, 347.4KB
==> Installing libimobiledevice --HEAD
==> Cloning https://git.libimobiledevice.org/libimobiledevice.git
Cloning into '/Users/deni/Library/Caches/Homebrew/libimobiledevice--git'...
==> Checking out branch master
Already on 'master'
Your branch is up to date with 'origin/master'.
==> ./autogen.sh
Last 15 lines from /Users/deni/Library/Logs/Homebrew/libimobiledevice/01.autogen.sh:
checking dynamic linker characteristics... darwin16.7.0 dyld
checking how to hardcode library paths into programs... immediate
checking for pkg-config... /usr/local/opt/pkg-config/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for libusbmuxd >= 1.1.0... no
configure: error: Package requirements (libusbmuxd >= 1.1.0) were not met:

Requested 'libusbmuxd >= 1.1.0' but version of libusbmuxd is 1.0.10

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables libusbmuxd_CFLAGS
and libusbmuxd_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

READ THIS: https://docs.brew.sh/Troubleshooting

libusbmuxdのバージョンが、古いらしいが、アップデート方法が不明だった。
いろいろ調べてみたら、usbmuxdというのでいけるっぽいので、削除して入れ直す。

$ brew uninstall --ignore-dependencies usbmuxd
$ brew install --HEAD usbmuxd
$ brew unlink usbmuxd
$ brew link usbmuxd
$ brew install --HEAD libimobiledevice
$ brew install ideviceinstaller

$ gem update cocoapodsで、cocoapodsのアップデートができなかったので、これも古いのを一旦削除して、入れ直す。

$ gem uninstall cocoapods
$ gen install cocoapods

$ pod setupが失敗するが、以下の手順で成功

$ pod repo remove master
$ pod setup

再度、 $ flutter doctorを試す。

[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)

これで実機テスト出来るようになりました!