Flutter Mac环境搭建
下载SDK
下载地址:https://flutter.dev/docs/development/tools/sdk/releases?tab=macos#macos
下载完成后解压
环境变量
打开配置文件
open ~/.bash_profile
添加变量
export PATH=/Users/用户名/Documents/flutter/flutter/bin:$PATH
使环境变量生效
source ~/.bash_profile
健康检测
flutter doctor
pixiao@192 Desktop % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.1, on Mac OS X 10.15.7 19H15 darwin-x64, locale
zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.1)
[✓] VS Code (version 1.55.1)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.
问题解决
- Android licenses全部接受
flutter doctor --android-licenses
# 然后一路 y 就可以了
- 如果提示没有安装
cocoapods
### 方式一(推荐,版本是1.10.0以上的版本)
# 安装
brew install cocoapods
# 卸载
brew uninstall cocoapods
# link
# 根据提示进行强制link就可以了,具体的那个命令忘了,但是这个步骤是必须的!!!
brew link cocoapods
### 方式二
# 安装
sudo gem install cocoapods (这个命令我会报错,ruby有问题)
sudo gem install cocoapods -v 1.8.4 (这个健康检测会提示版本较低)
# 卸载
sudo gem uninstall cocoapods
完美状态
其他设置
其他设置请到Flutter中文网进行查看
Flutter中文网:https://flutterchina.club/get-started/install/