下载flutter
推荐去官网下载,速度并不慢,网址:
https://flutter.io/setup-macos/
点击链接:
image
笔者在写这篇文章时候的链接为:
https://storage.googleapis.com/flutter_infra/releases/beta/macos/flutter_macos_v0.3.2-beta.zip
配置环境变量
先把刚才下载的flutter_macos_v0.3.2-beta.zip解压缩,笔者选择使用的目录是根目录下的app文件夹
image
配置环境变量,这里笔者使用命令行:
vim ~/.bash_profile
增加一行:
export PATH=/你的flutter文件夹所在位置/flutter/bin:$PATH
如 export PATH=/Users/louxun-k/flutter-2/bin:$PATH
保存一下,注意如果这个文件不存在,那么就新建一个。保存完毕之后运行命令:
source ~/.bash_profile
这个时候应该能运行flutter命令了,我们运行命令行:
flutter -h
这个时候应该能展示flutter的命令帮助:
image
检查环境
运行命令行:
flutter doctor
image
按照检测结果的说明,如果有[!] ✗ 标志,表示本行检测不通过,需要做一些设置或者安装一些软件。
[!] Android toolchain - develop for Android devices (Android SDK 27.0.3)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licens
需要运行
flutter doctor --android-licenses
image
这里界面会要求输入Y/N,一路输入Y就行了。
✗ ideviceinstaller is not installed; this is used to discover connected iOS devices.
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, seehttps://flutter.io/platform-plugins
To install:
brew install cocoapods
pod setup
运行命令:
brew install --HEAD libimobiledevicebrew install ideviceinstallerbrew install ios-deploybrew install cocoapodspod setup
这个步骤有点慢...
当然读者看到的也许和笔者不太一致,请酌情处理。
image
这里出现了个错误,按照说明,运行:
brew link --overwrite cocoapods
然后继续运行:
pod setup
如果直接运行这个命令,会相当慢,那么我们曲线解决:
cd ~/.cocoapods/reposgit clone https://github.com/CocoaPods/Specs.git
如果还是太慢,那么去
链接:https://pan.baidu.com/s/1mQ1VvslwwccdoLRi-I0pNg密码:lax1
下一份,解压缩到~/.cocoapods/repos/master目录
[✓] Android Studio (version 3.0)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
打开android studio, 打开plugin
image
输入flutter搜索,点击中间的 Search in repositories
image
点击install,顺利的话安装完毕之后重启android studio
再次运行
flutter doctor
image
注意这里有个坑,如果按照指引来做,会一直卡在这里。这里要先重装一下python,运行下面的命令:
brew reinstall python@2pip install six
再次运行
flutter doctor
至此,我们的环境就搭建完毕了,可以