1.切换gem sources
删除系统自带的sources gem sources --remove https://rubygems.org/
添加国内的sources gem source -a https://gems.ruby-china.com/
2.安装Homebrew (建议使用科大,速度快)
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
安装过程中可能会出现安装git 的提示,点击安装即可,
安装完成后,执行 brew -v 会有两个安全性警告
执行以下两个语句
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
3.安装rvm前,需安装gpg
brew install gpg
安装之后会出现如下提示
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
此时需执行
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
安装gpg keys
gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
4.使用 curl 安装 rvm
在这之前需要前往 /etc/hosts 文件中添加 185.199.108.133 raw.githubusercontent.com(记得备份hosts)
安装rvm
curl -L https://get.rvm.io | bash -s stable
安装成功提示 Thanks for installing RVM
还需执行 source /Users/yz/.rvm/scripts/rvm 才能正常使用rvm
5.将系统自带的ruby 倒入 rvm 中
执行 rvm automount
查看rvm 本地管理的ruby 版本
执行 rvm list
查看远程可安装的ruby 版本
执行rvm list known
选择你需要的ruby 版本安装
执行 rvm install [你要安装的ruby 版本号]
安装完成后系统会自动将你安装的ruby 版本设置为默认执行版本
可以通过 rvm use ext-ruby-2.6.3 --default 切换为一开始的ruby 版本,ext-ruby-2.6.3 只是我当前电脑的版本
6.安装cocoapods
卸载旧版 sudo gem uninstall cocoapods
安装新版 sudo gem install cocoapods
7. 最新Mac 安装cocoapods 使用
sudo gem install -n /usr/local/bin cocoapods
若要安装 cocoapods-art 需注意的是必须使用 rvm 安装了ruby 方能安装成功
8.安装本地资源库
国内源:
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git ~/.cocoapods/repos/trunk