Skip to main content

配置

IOS 环境配置

把 Flutter安装目录的bin目录配置到环境变量,然后把 Flutter 国内镜像也配置到环境变量里面

vim ~/.bash_profile
vim ~/.zshrc

export PATH=/Users/aishengwanwu/flutter_mac/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
让配置环境变量生效
source ~/.bash_profile
source ~/.zshrc

flutter --version 如果能出来版本说明flutter sdk配置成功。

tip

注意:如果配置完成后输入 flutter --version 告诉你 flutter 不是内置命令之类的错误的话,可能 sdk 没 有配置成功,也可能sdk下载的时候没有下载全

Xcode

如果电脑上面没有安装 brew的话首先第一步需要安装brew

https://brew.sh/

终端执行下面命令
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

分别执行下面命令

brew install cocoapods
pod setup
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch

执行

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
tip

注意:如果运行命令失败请运行 brew doctor并按照说明解决问题。

执行完成上面命令后然后重新运行: flutter doctor

命令

flutter doctor --android-licenses
tip

注意:提示输入 Y/N 的地方全部输入 Y

镜像源

Flutter 社区镜像
FLUTTER_STORAGE_BASE_URL: https://storage.flutter-io.cn
PUB_HOSTED_URL: https://pub.flutter-io.cn
清华大学 TUNA 协会镜像
FLUTTER_STORAGE_BASE_URL: https://mirrors.tuna.tsinghua.edu.cn/flutter
PUB_HOSTED_URL: https://mirrors.tuna.tsinghua.edu.cn/dart-pub