前言
在安全Flutter SDK完成后,我们通常需要执行flutter doctor
来检查是否需要安装其他依赖项,如果有依赖项未完成通常会有以下提示:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.14.6 18G103, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[!] iOS toolchain - develop for iOS devices (Xcode 11.1)
✗ 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 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
[✓] Android Studio (version 3.5)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Ultimate Edition (version 2018.2.3)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.34.0)
[✓] Connected devices (1 available)
! Doctor found issues in 3 categories.
其中开头有 [ ✗ ] 标识的项代表尚未安装的依赖项,在创建Flutter项目之前需要先安装这些依赖项,我们使用提示中的命令安装对应的依赖项。
安装 libimobiledevice and ideviceinstaller
安装方法:在终端中输入brew install --HEAD libimobiledevice
,如果顺利的话这一步将会被顺利安装完成。但是现实往往充满意外,以下是我整理的安装过程中发现的错误以及解决方案:
1) 网络异常时长会出现安装错误 [ Checksum mismatch ] 和 [ Failed to install vendor Ruby ]:
$ brew install --HEAD libimobiledevice
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby--2.6.3.mavericks.bottle.tar.gz
curl: (28) Operation timed out after 300491 milliseconds with 0 out of 0 bytes received
==> Downloading https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.3/portable-ruby--2.6.3.mavericks.bottle.tar.gz
########### 15.9%
curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
Error: Checksum mismatch.
Expected: ab81211a2052ccaa6d050741c433b728d0641523d8742eef23a5b450811e5104
Actual: 1d049e3de7b925fb6ca493beb5a65968f499d437325765e4cedd5f578ff9ab7c
Archive: /Users/anyone/Library/Caches/Homebrew/portable-ruby--2.6.3.mavericks.bottle.tar.gz
To retry an incomplete download, remove the file above.
Error: Failed to install vendor Ruby.
发生以上问题后,再次执行brew install --HEAD libimobiledevice
会得到一样的错误,因为第一次下载失败了,导致下载的文件并不完成,文件的SHA1和服务器上的不匹配,如果继续安装需要删掉已下载的旧文件,在终端中执行以下命令:
rm -rf /Users/anyone/Library/Caches/Homebrew/portable-ruby--2.6.3.mavericks.bottle.tar.gz
再次执行 libimobiledevice and ideviceinstaller的安装命令:brew install --HEAD libimobiledevice
2) 发生错误 [ Xcode alone is not sufficient on Mojave. ]:
$ brew install --HEAD libimobiledevice
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby--2.6.3.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby--2.6.3.mavericks.bottle.tar.gz
Updating Homebrew...
Error: Xcode alone is not sufficient on Mojave.
Install the Command Line Tools:
xcode-select --install
按照提示在终端中输入命令:xcode-select --install
,在弹出的窗口 [ 如下图 ] 中点击 安装
按钮 :
在接下来弹出的协议页面 [ 如下图 ] 点击 同意
按钮:
接下来会弹出下载进度窗口 [ 见下图 ],不用做任何操作,等待完成即可 :
等待软件下载完成后,点图窗口 [ 见下图 ] 中的
完成
按钮即可完成安装。接下来再回到终端窗口执行命令 :
brew install --HEAD libimobiledevice
3) 发生错误 [ configure: error: Package requirements (libusbmuxd >= 1.1.0) were not met ]:
Last 15 lines from /Users/anyone/Library/Logs/Homebrew/libimobiledevice/01.autogen.sh:
checking dynamic linker characteristics... darwin18.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 版本和所要安装的版本不一致的问题导致的。
解决方法:按照顺序执行下面的命令
#如果执行后提示错误 Error: No such keg: /usr/local/Cellar/libimobiledevice说明libimobiledevice还没有安装成功,直接执行下一条命令即可
brew uninstall --ignore-dependencies libimobiledevice
brew uninstall --ignore-dependencies usbmuxd
brew install --HEAD usbmuxd
brew unlink usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice
如果在执行命令brew uninstall --ignore-dependencies libimobiledevice
的时候提示错误 [Error:
No such keg: /usr/local/Cellar/libimobiledevice] 说明libimobiledevice还没有安装成功,直接执行下一条命令即可。
执行完以上命令后,libimobiledevice 就能顺利安装完成。