美文网首页iOS精品
CocoaPods问题大全

CocoaPods问题大全

作者: iOS小吴 | 来源:发表于2017-01-12 09:47 被阅读39次

1:软件源的替换   

ruby 的软件源( https://rubygems.org )使用的是亚马逊的云服务,所以自带的需要翻墙,但我们可以使用如下代码将官方的 ruby 源替换成国内淘宝的源(https://ruby.taobao.org/ )或者是由 Ruby China 社区专注维护的这个源(https://gems.ruby-china.org/ )。(我在镜像的时候开始用的是淘宝的,但会卡死,可能是不能用了,也可能是网速慢,在后面讲“坑”的时候会说)。在这我用的是Ruby China 社区专注维护的这个源(https://gems.ruby-china.org/)。

1:*首先,执行以下命令删除原来的ruby源:gem sources --remove https://rubygems.org/

执行命令后可在终端看见以下信息:https://rubygems.org/ removed from sources

*然后下一步添加你找到的可用的镜像源(这里我没有用淘宝的源:https://ruby.taobao.org/ ):gem sources -a https://gems.ruby-china.org/

*验证新源是否替换成功

gem sources -l

终端输出:

*** CURRENT SOURCES ***

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

到此ruby 源替已经换成国内的源

2  开始安装 CocoaPods

  2 .1如果gem太老,可以尝试用如下命令升级gem:sudo gem update --system 升级成功后会提示: Latest version currently installed. Aborting.

其他安装过程在此省略,在终端输入pod setup 时出现以下错误

下载安装CocoaPods

终端输入:sudo gem install -n /usr/local/bin cocoapods

接下来进行安装,执行:pod setup

Setting up CocoaPods master repo 这个状态一段时间,是因为要进行下载安装,而且目录比较大,需要耐心等待一下.安装成功后,你会看到:  setup completed

速度有些慢,耐心等待~~

{以查看下载进度----

cd ~/.cocoapods/      (这就是进入cocoa pods文件夹的代码)

du -sh * }

这样就下载安装好了CocoaPods

注意注意!!!

第一次执行pod setup时CocoaPods会将这些podspec索引文件更新到本地的~/.cocoapods目录下,这个索引文件比较大,所以第一次更新时非常慢.友好人士在国内的服务器建立了Cocoapods索引库的镜像,

所以执行索引跟新操作时候会快很多.具体操作方法如下:

pod repo remove master

//coding 上有每日更新的,建议使用这个

pod repo add master https://git.coding.net/CocoaPods/Specs.git

//或者用oschina,但是https 好像有问题,一直是403,所以用ssh的方式,这里需要到官网去配置ssh key

pod repo add master https://git.oschina.net/akuandev/Specs.git

如果提示失败或者setup不成功:

出现 [!] To setup the master specs repo, please run pod setup.

git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master

pod setup  //务必在手动下载代码后执行一次,执行后 Setup completed

//在执行

pod install --verbose --no-repo-update //避免去更新了

如果使用oschina 的 https Git clone不成功的话,建议到git.oschina.net中添加ssh key,换ssh方式下载源码

git clone git@git.oschina.net:akuandev/Specs.git  ~/.cocoapods/repos/master

如果你觉得pod setup不好你也可以用这方法手动下载

解决方案:首先通过终端cd到~/.cocoapods/repos下,在此目录下,输入终端命令:

git clone ‘https://github.com/CocoaPods/Specs.git’ master

剩下的就是漫长的等待,文件比较大,可能花费些时间,结果如下所示:

Cloning into ‘master’…

remote: Counting objects: 760233, done.

remote: Compressing objects: 100% (34/34), done.

remote: Total 760233 (delta 12), reused 0 (delta 0), pack-reused 760197

Receiving objects: 100% (760233/760233), 350.74 MiB | 44.00 KiB/s, done.

Resolving deltas: 100% (324910/324910), done.

Checking connectivity… done.

Checking out files: 100% (98969/98969), done.

注意注意:以下是中途可能出现的问题

1:error: RPC failed; curl 56 SSLRead() return error -9806(有可能有时候是你网络不好,如果还不行就执行后面解决方案) 解决方案如下

MacBook-Pro:$ 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

在终端依次执行以下命令行

brew remove git

 brew remove curl

 brew install openssl

 brew install --with-openssl curl

 brew install --with-brewed-curl --with-brewed-openssl git

然后在pod setup从试

2:error RPC failed; curl 56 SSLRead() return error -36(问题)或者  Unable to add a source with url https://github.com/CocoaPods/Specs.git named master-1 . You can try adding it manually in ~/.cocoapods/repos or via pod repo add . 是由于安装了多个Xcode导致路径变了,

Cloning into'master'...

error: RPC failed; curl56SSLRead()returnerror -36

fatal: The remote end hung up unexpectedly

fatal: early EOF

fatal: index-pack failed# 用以下这个命令来能解决问题:

$ sudo gem uninstall cocoa pods //交互时选择 y

$ pod repo remove master

# 然后重新安装即可

pod setup

或者看下面

建议先看完,再操作

1、只有一个xcode的情况,打开终端,输入以下命令:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

2、多个xcode

需要修改命令:

sudo xcode-select -switch /Applications/Xcode 7.3.1.app/Contents/Developer

根据你默认的xcode来修改在/Applications/和/Contents/Developer中间的app的名字,如果你默认的是Xcode x.x.x.app,中间就要替换掉。

也可以在终端里输入:

sudo xcode-select --print-path

输出:

/Applications/Xcode.app/Contents/Developer

这步结束。

然后删除repos目录下master

sudo rm -fr ~/.cocoapods/repos/master

再执行pod setup,等了一会,成功了。

ps:问题还存在,把xcode全部卸载,只装一个最新的。

打开用了pods的工程,执行pod update,报错

[!] The dependency `FMDB (~>2.3)`isnotusedinany concrete target.等等

网上找到答案,修改Podfile格式(这里就不做这方面的解释了)

pod install --verbose --no-repo-update

pod update --verbose --no-repo-update

pod install与pod update区别:

1.使用pod install来安装新的库,即使你的工程里面已经有了Podfile,并且已经执行过pod install命令了;所以即使你是添加或移除库,都应该使用pod install。

2.使用pod update [PODNAME] 只有在你需要更新库到更新的版本时候用。

如果还遇见了其它方面的问题,欢迎加入608099662群进行交流

相关文章

网友评论

    本文标题: CocoaPods问题大全

    本文链接:https://www.haomeiwen.com/subject/mokxbttx.html