iOS文章iOS

cocoapods安装的坑(pod setup等待时间长)

2016-12-06  本文已影响7262人  何年何月

正常安装cocoapods流程大致如下:


$ gem sources -l
$ gem sources --remove https://rubygems.org/
$ gem sources -a https://ruby.taobao.org/
$ gem sources –l

更新ruby
$ sudo gem update —system
$ sudo gem install cocoapods
 sudo gem install -n /usr/local/bin cocoapods

pod setup

解决坑:
我遇到的问题比较奇葩,cocoapods安装一切正常,1.1.1版本,但是使用的时候提示各种错误,然后我反复卸载安装,pod --version是正常的,就是不能用。

提示1.


[!] An error occurred while performing `git pull` on repo `master`.
[!] /usr/bin/git pull --ff-only

解决方案:// 删除cocoapods重新安装下载
sudo rm -fr ~/.cocoapods/repos/master
然后再: pod setup

pod setup的时候等待的时间特别长,无法成功!取消pod setup直接使用cocoapods提示如下:

提示2.


pod setup
Setting up CocoaPods master repo
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '—' to separate paths from revisions, like this:
'git <command> [<revision>…] — [<file>…]'
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '—' to separate paths from revisions, like this:
'git <command> [<revision>…] — [<file>…]'
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '—' to separate paths from revisions, like this:
'git <command> [<revision>…] — [<file>…]'
  $ /usr/bin/git -C /Users/wangmengfei/.cocoapods/repos/master pull —ff-only

在终端输入

cd ~/.cocoapods/repos/
du -sh *
3299556-c95fb1aa92bcbcdf.jpg

最终解决方案:####

在GitHub上找到Specs 后fork到自己的工程,然后使用工具GitHub Desktop工具把Specs下载下来,更名成master ,替换路径~/.cocoapods/repos目录下的master。
就可以正常使用了

原因分析####

就是国内网站更新GitHub太慢,并且很容易失败,所以才会出现这种问题,解决方法就是直接下载下来替换Mac里相对位置的文件即可。

上一篇 下一篇

猜你喜欢

热点阅读