cocoaPods需要gem工具来安装,而gem则需要ruby环境的支持:
1.如果rvm的版本过低就无法更新gem。
1> .查看ruby版本:$ /usr/bin/ruby -v
使用homeBrew安装rvm:
2> .安装homeBrew:
a.安装homeBrew需要Xcode依赖库的支持,先装Xcode。
xcode-select --install
b.安装homeBrew(注意以下是一条命令)。
/usr/bin/ruby -e "
(
c
u
r
l
−
f
s
S
L
h
t
t
p
s
:
/
/
r
a
w
.
g
i
t
h
u
b
u
s
e
r
c
o
n
t
e
n
t
.
c
o
m
/
H
o
m
e
b
r
e
w
/
i
n
s
t
a
l
l
/
m
a
s
t
e
r
/
i
n
s
t
a
l
l
)
"
c
.
查
看
是
否
安
装
成
功
(
一
般
输
出
"
Y
o
u
r
s
y
s
t
e
m
i
s
r
e
a
d
y
t
o
b
r
e
w
.
"
成
功
)
。
b
r
e
w
d
o
c
t
o
r
d
.
查
看
安
装
的
h
o
m
e
B
r
e
w
版
本
:
(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" c.查看是否安装成功(一般输出"Your system is ready to brew."成功)。 brew doctor d.查看安装的homeBrew版本:
(curl−fsSLhttps://raw.githubusercontent.com/Homebrew/install/master/install)"c.查看是否安装成功(一般输出"Yoursystemisreadytobrew."成功)。brewdoctord.查看安装的homeBrew版本: brew -v
3>.安装rvm(ruby):
\curl -sSL https://get.rvm.io | bash -s stable
b.查看rvm版本:
rvm -v
c.查看ruby镜像地址:
gem sources -l
d.更换gem源地址。
gem sources --remove https://rubygems.org/
gem sources --add https://gems.ruby-china.com/
2.如果gem版本太低就无法更新pod版本。
查看gem版本:
gem -v
升级gem版本:
sudo gem update --system
3.安装pod最新版本:
sudo gem install -n /usr/local/bin cocoapods --pre
4、重装cocopods:
1>. 卸载命令:
sudo gem uninstall cocoapods
2>. 先查看本地安装过的cocopods相关东西,命令如下:
gem list --local | grep cocoapods
2.1>. 查看pod安装路径:
which pod
2.2>. 移除之前安装过的资源:
sudo rm -rf /usr/local/bin/pod
3>. 安装指定版本的pod:
$ sudo gem install cocoapods --version 0.24.0