流程概述:
1.安装homebrew
2.安装gpg
3.安装rvm
4.安装ruby
5.更换gem源
6.安装cocospods
1.从国内源安装homebrew安装
/bin/zsh -c "$(curl -fsSL <https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
2.安装gpg
brew install gnupg
3.安装rvm
curl -sSL <https://get.rvm.io> | bash -s stable
报错:
curl: (7) Failed to connect to raw.githubusercontent.com port 443 after 130 ms: Couldn't connect to server
What Is My IP Address? Free IP Lookup
进入网站查询 raw.githubusercontent.com
之后按照格式编辑本机Hosts,可以下个App方便编辑
185.199.108.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com
再次执行安装rvm:
curl -sSL <https://get.rvm.io> | bash -s stable
再次报错:gpg: 无法检查签名:缺少公钥
执行以下2条指令:
command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
第三次安装
curl -sSL <https://get.rvm.io> | bash -s stable
安装成功
配置环境变量:ESC 输入:wq回车即可退出
vi ~/.bash_profile
(source ~/.rvm/scripts/rvm)
查看版本:
vi ~/.bash_profile
4.安装Ruby
列出Ruby的所有版本:
rvm list known
检查安装已安装的ruby版本:
rvm list
卸载已安装的Ruby版本:
rvm remove x.y.z
安装Ruby:
rvm install x.y.z
我在这里安装2.7.2的是版本,版本不要过高或过低,否则安装cocospods可能会报错
执行rvm install 2.7.2 后报错:
Error running '__rvm_make -j8',
please read /Users/js/.rvm/log/1702274220_ruby-2.7.2/make.log
There has been an error while running make. Halting the installation.
按顺序执行以下3条指令:
brew uninstall --ignore-dependencies openssl@3
rm -rf /usr/local/etc/openssl@1.1
brew reinstall openssl@1.1
再次执行
rvm install 2.7.2
安装成功
5.gem更换国内源
查看镜像
gem sources -l
更换源
gem sources --remove <https://rubygems.org/>
gem sources --add <https://gems.ruby-china.com>
6.安装cocospods
sudo gem install cocoapods
耐心等待安装 --没反应不是卡了,要等很久
第二种安装方法:
brew install cocoapods
更新:
brew upgrade cocoapods
安装结束:
查看版本:
brew install cocoapods
安装成功