1、安装HomeBrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2、安装RVM
$ gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
$ \curl -sSL https://get.rvm.io | bash -s stable
$ source ~/.bashrc
$ source ~/.bash_profile
3.切换ruby源
$ echo "ruby_url=https://cache.ruby-china.com/pub/ruby" > ~/.rvm/user/db
3、列出可安装的ruby版本列表
$ rvm list known
4、安装一个ruby版本(这里我选择的是3.0.0版本,当然你也可以选择其他的)
$ rvm install 3.0.0
5、设置为默认版本
$ rvm use 3.0.0 --default
7、更改电脑的host文件中有关GitHub的内容(跳过此步骤也能安装,但大概率会遇到访问超时的情况)
1)打开终端
2)输入sudo vi /etc/hosts
3)输入密码
4)进入文件hosts,然后按“i”,进入编辑模式
5)去这里https://raw.fastgit.org/521xueweihan/GitHub520/main/hosts复制内容
6)把你的host添加到最后
7)control+c推出编辑模式
8)输入:wq,保存退出
6、正式开始安装CocoaPods
$ sudo gem install -n /usr/local/bin cocoapods
网友评论