0. 如果出错可以删除
```
进 在/Users/电脑名称/目录下
cd ~/
显示隐藏文件,
删除 .cocoapods文件夹;
删除 .rvm文件夹;
```
1. 换源
```
sudo gem sources --remove [https://rubygems.org/](https://rubygems.org/)
sudo gem sources --add [https://gems.ruby-china.com/](https://gems.ruby-china.com/)
```
2. 安装 homebrew
```
/bin/zsh -c "$(curl -fsSL [https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh](https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh))"
```
选 1 就行,按流程走
PS: 最好使用国内镜像,中科大源
```
/bin/bash -c "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh](https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh))"
/bin/bash -c "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh](https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh))"
```
国内镜像
```
/bin/zsh -c "$(curl -fsSL [https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh](https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh))"
/bin/zsh -c "$(curl -fsSL [https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh](https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh))"
```
按需可能执行以下操作
```
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
```
curl -L [https://get.rvm.io](https://get.rvm.io/) | bash -s stable
source ~/.rvm/scripts/rvm
rvm reload
```
4. 安装 ruby
```
rvm install 3.0.0
```
5. 安装 cocoapods 和其他可能需要的库
```
sudo gem install xcpretty
sudo gem install xcodeproj
sudo gem install cocoapods
```