MacOS Flutter 环境配置

Flutter5年前 (2020)发布 admin
409 0

一、/etc/profile (建议不修改这个文件 )

全局(公有)配置,不管是哪个用户,登录时都会读取该文件。

二、/etc/bashrc (一般在这个文件中添加系统级环境变量)

全局(公有)配置,bash shell执行时,不管是何种方式,都会读取此文件。

三、~/.bash_profile (一般在这个文件中添加用户级环境变量)

每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!
但是有时在.bash_profile 文件中的环境变量并没有起到作用
这时可以查看使用的Mac OS X是什么样的Shell

vim ~/.bash_profile

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=/你的flutter文件夹所在位置/flutter/bin:$PATH

source ~/.bash_profile

配置ruby源

https://gems.ruby-china.com/

$ gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
$ gem sources -l
https://gems.ruby-china.com
# 确保只有 gems.ruby-china.com

现用.bash_profile

export PATH=/Users/cocashu/downloads/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PS1='[%n@%m~%1~]#'

#安装brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

brew安装cocoapods
方式一:
# brew cleanup -d -v    
# brew install cocoapods

方式二:
# ruby -e "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/master/install](https://raw.githubusercontent.com/Homebrew/install/master/install))" < /dev/null 2> /dev/null
# brew install cocoapods
cocoapods1.10.0安装成功以后,需要链接,链接成功即是最新版cocoapods
 brew link cocoapods
# brew link --overwrite cocoapods

HTTP host “https://maven.google.com/” is not reachable.
HTTP host “https://cloud.google.com/” is not reachable.

这是因为墙的原因,导致Google无法访问造成的。很多网络文章通过修改flutter文件夹下的文件来绕过这个问题,感觉不是很好。
为了这个问题,flutter提供了国内的镜像源,在配置文件 .zprofile中配置一下就可以了

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

© 版权声明

相关文章