更换新mac 再次安装CocoaPods

·  阅读 1853
  1. 确认没有pod
~ % pod --version

zsh: command not found: pod
复制代码
  1. 查看当前ruby环境
ruby -v
复制代码

默认是 ruby 2.2.3p0 (2020 ....

此时需要安装最新版本

brew install ruby
复制代码

安装完成, 重新打开终端 查看

ruby -v

ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin20]
复制代码
  1. RVM 是一个便捷的多版本 Ruby 环境的管理和切换工具.安装它,官网:rvm.io/
//安装
curl -sSL https://get.rvm.io | bash -s stable


//报错
~ % curl -sSL https://get.rvm.io | bash -s stable

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

//安装
~ % curl -L get.rvm.io | bash -s stable
复制代码

此时raw.githubusercontent.com无法访问,如何处理

raw.githubusercontent.com resolves to the following 4 IPv4 addresses:

-   **185.199.108.133**
-   **185.199.109.133**
-   **185.199.110.133**
-   **185.199.111.133**
复制代码
  • 修改host
~ % sudo vi /etc/hosts
复制代码

添加ip映射 185.199.108.133  raw.githubusercontent.com

  • 再次执行安装
~ % curl -L get.rvm.io | bash -s stable
复制代码
Installation of RVM in /Users/XXX/.rvm/ is almost complete:

  * To start using RVM you need to run `source /Users/mg10-ly/.rvm/scripts/rvm`

    in all your open shell windows, in rare cases you need to reopen all shell windows.

Thanks for installing RVM 🙏
复制代码
  • 如果还是不行就科学上网

  • other

rvm get stable(rvm更新)
rvm --version(rvm版本)
复制代码
  1. gem
  • gem sources -l(查看当前源)
  • gem --version(gem版本)
  • sudo gem update --system(gem更新)
  • gem sources --remove rubygems.org/ (移除之前的源)
  • gem sources --add gems.ruby-china.com/ (国内新源)
 ~ % gem sources --remove https://rubygems.org/

https://rubygems.org/ removed from sources

~ % gem sources --add https://gems.ruby-china.com/

https://gems.ruby-china.com/ added to sources

 ~ % sudo gem update --system                      

Latest version already installed. Done.
复制代码
  1. 此时准备工作ok, 开始 gem 安装 cocoapods
sudo gem install -n /usr/local/bin cocoapods
复制代码
  1. 此时pod已经安装完毕
~ % pod --version

1.11.2
复制代码
分类:
iOS
标签:
分类:
iOS
标签:
收藏成功!
已添加到「」, 点击更改