export PUB_HOSTED_URL=https://pub.Flutter-io.cnexport FlutteR_STORAGE_BASE_URL=https://storage.Flutter-io.cn
下载Flutter下载Flutterflutter官网下载地址flutter github下载地址进入你想放置Flutter的目录cd ~/development
解压下载文件,记住改为你自己下载的版本号,按Y确认即可unzip ~/Downloads/Flutter_macos_v0.5.1-beta.zip
将Flutter添加到path中export PATH=`pwd`/Flutter/bin:$PATH
此时你会发现,你打开一个新的命令行窗口是,运行Flutter doctor
,会报Flutter不存在的错误,是因为环境变量还没全局生效
Flutter doctor
错误详情
AndroID toolchain - develop for AndroID devices (AndroID SDK version 30.0.2) ✗ AndroID licenses not accepted. To resolve this, run: Flutter doctor --androID-licenses[✗] Xcode - develop for iOS and macOS ✗ Xcode installation is incomplete; a full installation is necessary for iOS development. Download at: https://developer.apple.com/xcode/download/ Or install Xcode via the App Store. Once installed, run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -runFirstLaunch ✗ CocoaPods not installed. CocoaPods is used to retrIEve the iOS and macOS platform sIDe's plugin code that responds to your plugin usage on the Dart sIDe. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://Flutter.dev/platform-plugins To install: sudo gem install cocoapods[!] AndroID Studio (version 4.1) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality.[!] VS Code (version 1.52.0) ✗ Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemname=Dart-Code.Flutter[!] Connected device ! No devices available
上面的错误信息是告诉你东西未安装完,比如xcode,AndroID Studio,AndroID Studio的dart、fultter插件,CocoaPods,VS Code的Flutter插件未安装
xcode安装在app store搜索xcode,安装即可运行下面命令再次运行Flutter doctor会发现关于xcode的错误消失了sudo xcode-select --switch /Applications/Xcode.app/Contents/Developersudo xcodebuild -runFirstLaunchsudo gem install cocoapods
AndroID Studio安装下载安装Android Studio打开AndroID Studio中Preferences,选择Plugins,输入Flutter与dart,install安装即可VS Code中Flutter插件安装打开vscode,点击扩展,输入Flutter,install安装,安装之后重新打开vscode即可再次运行Flutter doctor
,关于AndroID Studio相关的错误可能还是有,运行下面的命令// 注意AndroIDStudio版本号ln -s ~/library/Application\ Support/Google/AndroIDStudio4.1/plugins ~/library/Application\ Support/AndroIDStudio4.1
再次运行Flutter doctor
,下面这样就都正常了环境变量配置查看Flutter的环境配置路径pathecho $PATH// 可以看到Flutter的路径为/Users/name/development/Flutter/bin:
打开环境配置文件open ~/.bash_profile
或者vim编辑vim ~/.bash_profile
如果在编辑bash_profile时发现文件不存在// 创建bash_profile文件touch .bash_profile
bash_profile文件存在时,添加下面内容// 添加国内镜像export PUB_HOSTED_URL="https://pub.Flutter-io.cn"export FlutteR_STORAGE_BASE_URL="https://storage.Flutter-io.cn"// 添加安装路径,上面获取到的export PATH="/Users/name/development/Flutter/bin:$PATH"
更新环境配置source ~/.bash_profile
重启编辑器即可,会发现在最终的bash_profile文件
// .bash_profile# HomeBrewexport HOMEBREW_BottLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottlesexport PATH="/usr/local/bin:$PATH"export PATH="/usr/local/sbin:$PATH"export PUB_HOSTED_URL="https://pub.Flutter-io.cn"export FlutteR_STORAGE_BASE_URL="https://storage.Flutter-io.cn"# name为自己电脑的名称export PATH="/Users/name/development/Flutter/bin:$PATH"source ~/.bashrc# HomeBrew END
总结 以上是内存溢出为你收集整理的01-mac flutter环境搭建全部内容,希望文章能够帮你解决01-mac flutter环境搭建所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)