正常安装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里相对位置的文件即可。









网友评论
https://github.com/CocoaPods/Specs
使用迅雷下载
隐藏文件中有.git 最好是拖过去切换其中的3个,.git和.gitignore 留着,不然就像楼上会出错
(The `master` repo is not a git repo.)
按照你的方法,master复制进去,再pod setup出现的
2. git clone https://github.com/CocoaPods/Specs.git
3. 更改 Specs 文件名,改成master
4. 执行pod setup,等待其完成