Mac上搭建Flutter开发环境
程序员文章站
2022-05-04 11:44:54
1、 去flutter官网下载其最新可用的安装包,官网地址:https://flutter.io/sdk-archive/#macos2、解压安装包到你想安装的目录cd ~/developmentunzip ~/Downloads/flutter_macos.zip3、配置环境变量打开根目录下的隐藏文件 .bash_profile(Finder显示隐藏文件的快捷键 command + shift + .),把下边的三行 命令粘贴进去,保存文件(可以用命令行打开文件也行)再执行一下该文件 ....
- 1、 去flutter官网下载其最新可用的安装包,官网地址:https://flutter.io/sdk-archive/#macos
- 2、解压安装包到你想安装的目录
cd ~/development
unzip ~/Downloads/flutter_macos.zip
- 3、配置环境变量
打开根目录下的隐藏文件 .bash_profile(Finder显示隐藏文件的快捷键 command + shift + .),把下边的三行 命令粘贴进去,保存文件(可以用命令行打开文件也行)
再执行一下该文件 source ~/.bash_profile,第三行是sdk安装目录
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=${PATH}:/Users/duanmu/FlutterDev/flutter/bin
如果安装了zsh,需要在.zshrc配置如下命令
source ~/.bash_profile
或source ~/.zshrc
- 4、终端执行
flutter doctor
使用vs code运行Dart文件, run code报错:/bin/sh: dart: command not found
原因是本地默认shell更改造成的,只需在.zshrc中添加如下代码,在保存就可以了
#dart
export DART_HOME=/Users/XXX/XXX/flutter/bin/cache/dart-sdk/bin
export PATH="${DART_HOME}:${PATH}"
ios真机运行时错误:
error: Building for iOS Simulator, but the linked and embedded framework 'App.framework' was built for iOS. (in target 'Runner' from project 'Runner')
解决方法:rm -rf ios/Flutter/App.framework
参考: https://www.jianshu.com/p/6b049adfd211
https://book.flutterchina.club/chapter1/install_flutter.html
本文地址:https://blog.csdn.net/quanqinayng/article/details/107382881
下一篇: 使用树莓派打造一个音乐播放器