最近在 MacOSX 上安装 flutter 也遇到一些问题。不是 MacOS Mojave 的问题,而是 flutter 依赖的一个开源库,它的依赖树出现版本不兼容问题。

运行 flutter doctor 出现如下提示。

[!] iOS toolchain - develop for iOS devices (Xcode 10.0) ✗ libimobiledevice and ideviceinstaller are not installed. To install, run: brew install –HEAD libimobiledevice brew install ideviceinstaller ✗ ios-deploy not installed. To install: brew install ios-deploy ✗ CocoaPods not installed. 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 install: brew install cocoapods pod setup

按照提示,运行 brew install --HEAD libimobiledevice 出现如下提示。

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

brew 发现 usbmuxd 这个库最高版本就是 1.0.10,github 上最新 release 版本也是 1.0.10。压根儿就没有 1.1.0 这个版本存在。

不过细看,发现 usbmuxd 这个库的最新版本,就是这个 1.0.10 是 2014 年发布的,算是老古董了。

所以安装 usbmuxd 的 head 版本试试。

brew unlink usbmuxd  # 否则会 reinstall 失败
brew reinstall --HEAD usbmuxd  # 直接从 github 的 master HEAD 安装

brew install --HEAD libimobiledevice

然后,就成了。囧rz…

依赖树的问题,万一遇到,还是得手动一个一个解决。没办法。

一个结论就是,要用 brew install —HEAD,就要忍受 nightly 的不稳定,这是必然付出的代价。flutter 现在还是 beta 版本,依赖 nightly 的开源库也情有可原。遇到问题,就自己撸起手解决吧。