CocoaPods是什么不多说,自己网上去查。今天主要讲CocoaPods的安装问题:
1.(这是原来的,请看下面的更新)首先用淘宝的Ruby镜像来访问CocoaPods,打开终端输入以下命令:
(1)gem sources --remove http://ruby.taobao.org/
(2)gem sources -a https://ruby.taobao.org/
(3)gem sources -l
更新:淘宝源不能用了,可以用Ruby China 社区专注维护的这个源(https://gems.ruby-china.org/ )。
首先,执行以下命令删除原来的ruby源:
gem sources --remove https://rubygems.org/
执行命令后可在终端看见以下信息:
https://rubygems.org/ removed from sources
然后下一步添加你找到的可用的镜像源:
gem sources -a https://gems.ruby-china.org/
验证新源是否替换成功:
gem sources -l
只有在终端中出现下面文字才表明你上面的命令是成功的:
*** CURRENT SOURCES ***
2.更新升级gem,如果它的版本过低也可能导致安装失败,在终端输入以下命令:
sudo gem update --system
3.安装CocoaPods:
OS X 10.11以前,在终端输入以下命令:
sudo gem install cocoapods
OS X 10.11以后,在终端输入以下命令:
sudo gem install -n /usr/local/bin cocoapods
4.初始化:
在终端输入以下命令:
pod setup
问题最多的就是这一步,第一次安装完成可能要一个小时左右,所以要耐心等待,如果这一步完成了,那么恭喜你已经成功安装了CocoaPods。想知道自己有没有安装完成,可以在终端输入以下命令:
pod --version
显示出版本就说明成功了。
5.问题梳理:
(1)在终端输入以下命令:
pod repo list
结果为0 repos时说明安装不成功,自己可以查看下自己的安装步骤,看看是哪一步出现了问题。
(2)出现以下错误:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj
在网上寻找的解决方法:
在终端中输入:sudo nvram boot-args="rootless=0"; sudo reboot
然后你的电脑会重启
之后再输入sudo gem install cocoapods -V
就可以了。
(3)pod setup时出现以下错误:
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -36
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.
自己按照提示在终端输入以下命令:
pod repo add master https://github.com/CocoaPods/Specs.git
还是报错!
在网上查到的解决办法:在终端输入以下命令:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
后面的地址你可以打开Xcode显示包内容,找到那个文件夹拖到终端里面。
(4)试过以上所有解决办法,还是没有安装成功:
重新安装(其实我就是这样安装成功的):
首先,删除.cocoapods目录,在终端输入以下命令:
sudo rm -rf ~/.cocoapods/
然后,重新下载安装,在终端输入以下命令:
pod setup
ps:很多人说这两句解决了他们的问题
$ sudo gem install -n /usr/local/bin cocoapods
$ Git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
网友评论
最后,手机4G开共享网络!分分钟搞定~!有流量就是任性~!😄
Setting up CocoaPods master repo
$ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
remote: Counting objects: 1119527, done.
remote: Compressing objects: 100% (207/207), done.
remote: Total 1119527 (delta 98), reused 1 (delta 1), pack-reused 1119306
Receiving objects: 100% (1119527/1119527), 381.99 MiB | 1.03 MiB/s, done.
Resolving deltas: 100% (524530/524530), done.
Checking out files: 100% (140762/140762), done.
CocoaPods 1.2.1.beta.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.2.1.beta.1
Setup completed
Cloning into 'master'...
remote: Counting objects: 1117753, done.
remote: Compressing objects: 100% (75/75), done.
error: RPC failed; curl 56 SSLRead() return error -98060 KiB/s
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
我的报这样错误,还没搞定,楼主给看看哈
错误如下:
jerdeMacBook-Pro:~ jer$ sudo gem install -n /usr/local/bin cocoapods
Password:
ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR: You must add /O=Digital Signature Trust Co./CN=DST Root CA X3 to your local trusted store
ERROR: SSL verification error at depth 2: self signed certificate in certificate chain (19)
ERROR: Root certificate is not trusted (/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA)
Successfully installed cocoapods-1.1.1
Parsing documentation for cocoapods-1.1.1
1 gem installed
【
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -9806
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
】
,还有您说主要原因是Ruby环境需要2.2以上,我用gem -v查看了输出 2.6.8,我的版本也是ok的啊
$ Git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
这两句有用,转载表示感谢
Setting up CocoaPods master repo
Updating 5c0af14..04d7c83
Fast-forward
.../0.2.9/MAGComfortTextInput.podspec.json | 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 Specs/d/a/0/MAGComfortTextInput/0.2.9/MAGComfortTextInput.podspec.json
From https://github.com/CocoaPods/Specs
5c0af14..04d7c83 master -> origin/master
[!] The `master` repo requires CocoaPods 1.0.0 - (currently using 0.39.0)
Update CocoaPods, or checkout the appropriate tag in the repo.
terencedeMacBook-Pro:~ Terence$
你好,我想依旧用0.39的cocoapods,请问要怎么设置了,安装了0.39的cocoapods,setup的时候依旧提示[!] The `master` repo requires CocoaPods 1.0.0 - (currently using 0.39.0)
Setting up CocoaPods master repo
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': SSLRead() return error -9806
MacBook-Pro:~ wang$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Password:
MacBook-Pro:~ wang$ pod setup
Setting up CocoaPods master repo
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -9806
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
MacBook-Pro:~ wang$ sudo rm -rf ~/.cocoapods/
Password:
MacBook-Pro:~ wang$ pod setup
Setting up CocoaPods master repo
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': SSLRead() return error -9806
MacBook-Pro:~ wang$
大神 我这是什么情况 为什么还不行呢