完成之后再次输入 $ flutter doctor 进行检查看还有什么需要支持的
$ flutter doctor
输入如下:
MacBook-Pro:~ MacBook-Pro$ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E227, locale zh-Hans-CN) [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [!] iOS toolchain - develop for iOS devices (Xcode 10.1) ✗ libimobiledevice and ideviceinstaller are not installed. To install with Brew, run: brew update brew install --HEAD usbmuxd brew link usbmuxd brew install --HEAD libimobiledevice brew install ideviceinstaller ✗ ios-deploy not installed. To install: brew install ios-deploy ✗ Brew can be used to install tools for iOS device development. Download brew at https://brew.sh/. [!] Android Studio (version 3.4) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. [!] VS Code (version 1.34.0) ✗ Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [!] Connected device ! No devices available
我发现上一个 [✗] Android toolchain - develop for Android devices 的 问题已经好了。
那么接着在来处理 [!] iOS toolchain - develop for iOS devices (Xcode 10.1) 问题。
这里呢,我们需要用到MAC的 Homerew,我这里也写了Homerew安装方式 超级简单。
安装好 Homerew 之后,根据问题中的提示运行 brew xxx 命令,因为Flutter需要用到这些资源库。
这里呢我把这一步需要解决的问题单独拷贝出来,方便观看:
[!] iOS toolchain - develop for iOS devices (Xcode 10.1) ✗ libimobiledevice and ideviceinstaller are not installed. To install with Brew, run: brew update brew install --HEAD usbmuxd brew link usbmuxd brew install --HEAD libimobiledevice brew install ideviceinstaller ✗ ios-deploy not installed. To install: brew install ios-deploy ✗ Brew can be used to install tools for iOS device development. Download brew at https://brew.sh/.
当我在运行
$ brew install --HEAD usbmuxd
出现
Error: Your Xcode (10.1) is too outdated. Please update to Xcode 10.2.1 (or delete it). Xcode can be updated from the App Store.
这个就自己看看或者翻译一下就知道了,当前的 Xcode (10.1) 版本低了,需要更新到 10.2.1或者更高。如果你没有安装Xcode需要去下载安装 需要登录苹果账号进入下载列表。
更新好xcode之后,继续运行下面的 brew 命令。
其他的错误我就不一一列出来了,不知道的可以直接百度,或者翻译看看就明白怎么弄了。
接下来这个错误,只需要在 Android Studio 上面装上 Flutter 插件,以及支持下 Dart 环境。
[!] Android Studio (version 3.4) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality.
打开 Android Studio
安装过程中会询问你是否要安装 Dart,点YES就行了,安装完成之后需要重启 Android Studio 才会生效。
另外提示一下 在使用 Android Studio 进行 New 一个 Flutter 项目的时候会卡主一段时间,我这边是卡了挺久了,点击 Start a new Flutter project 就卡主不动了, 重启了 Android Studio 几次,后面等了一段时间才可以。
另外需要使用 Android Studio 的模拟器,可以自行百度 Android Studio 怎么添加模拟器。
再次输入 $ flutter doctor 进行检查看还有什么需要支持的
$ flutter doctor
输出
MacBook-Pro:~ MacBook-Pro$ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E227, locale zh-Hans-CN) [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] iOS toolchain - develop for iOS devices (Xcode 10.2) [✓] Android Studio (version 3.4) [!] VS Code (version 1.34.0) ✗ Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [✓] Connected device (1 available) ! Doctor found issues in 1 category.
看到没,只有一个 VS Code 的错误没有打勾了 Nice!
对于这个错误, 其实也是说VSCode需要支持 Flutter 插件 跟 Dart 插件,我们打开VSCode这样操作:
我们只需要搜索flutter install 就好了,而且安装了flutter 则会默认一块安装了 Dart , 但是它依然会右下角弹出提示框。关了就可以了,或者你不放心可以在上面在搜索 Dart ,你就会看到它也是属于已安装的状态。
最后我们再次输入 $ flutter doctor 检查
$ flutter doctor
输出
MacBook-Pro:~ MacBook-Pro$ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E227, locale zh-Hans-CN) [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] iOS toolchain - develop for iOS devices (Xcode 10.2) [✓] Android Studio (version 3.4) [✓] VS Code (version 1.34.0) [✓] Connected device (1 available) • No issues found
恭喜,到此为止,我们的环境就搭建完毕了!
在VSCode上面使用模拟器或者真机都是比较方便的。