安装CocoaPods一些命令记录

安装 rvm

$ curl -L get.rvm.io | bash -s stable 

出现下面错误信息

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

解决办法:

1、查看网址

1. 打开网站https://www.ipaddress.com/
2. 查询一下 raw.githubusercontent.com对应的IP 地址

ip查看.png

3. 替换系统的host文件

注意:最好复制一份出来在更改

etc.png
hosts.png
hosts_ip.png

4. 然后执行命名:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

如果安装还是出现问题,可以试下借用知乎的方式:https://zhuanlan.zhihu.com/p/111014448

//安装Homebrew, 知乎的方式已经全部替换为国内地址

$ /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

安装完Homebrew,在执行安装rvm

$ curl -L get.rvm.io | bash -s stable

$ curl -sSL https://get.rvm.io | bash -s stable

rvm_gpg.png
$ source ~/.bashrc
$ source ~/.bash_profile 
$ rvm -v

rvm 1.29.10 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

列出ruby可安装的版本信息

$ rvm list known

# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.9]
[ruby-]2.5[.7]
[ruby-]2.6[.5]
[ruby-]2.7[.0]
ruby-head

安装一个ruby版本

$ rvm install 2.7.0

设置为默认版本

$ rvm use 2.7.0 --default

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.

设置失败,执行下面命令

$ source ~/.rvm/scripts/rvm
$ rvm use 2.7.0 --default

Using /Users/bobo/.rvm/gems/ruby-2.7.0

在看默认版本号

$ ruby -v

ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]

安装cocoapods

如果之前装过cocopods,最好先卸载掉,卸载命令:

$ sudo gem uninstall cocoapods

先查看本地安装过的cocopods相关东西,命令如下:

$ gem list --local | grep cocoapods

然后逐个删除吧:

//示例
$ sudo gem uninstall cocoapods-core

使用Homebrew安装CocoaPods

安装Homebrew

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

....

==> Installation successful! 

表示安装成功

接着安装ruby,继续在终端中进行

$ brew install ruby 

安装完成后替换一下ruby源

$ gem sources -l
*** CURRENT SOURCES ***
https://rubygems.org/

替换ruby源

gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/

查看ruby源

$ gem source -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com/

安装CocoaPods

$ sudo gem install -n /usr/local/bin cocoapods


出现 33 gems installed ,,表示安装成功

然后执行

$ pod setup

最后在iOS工程中的Podfile目录下执行下面命令

$ pod install

$ pod update

你可能感兴趣的:(安装CocoaPods一些命令记录)