因为电脑升级了,突然准备升级一下第三方框架,发现cocoapods用不了了。故重新安装一下,但是过程还是出现很多问题,故来写一篇文章记录一下。
安装cocoapods需要使用ruby环境,因为以前安装过,所以不需要再安装了。如果没有就去自行百度吧。因为一般mac系统都自带安装了。如果不知道自己有没有ruby,可以用ruby -v 查看当前ruby版本。
安装:
首先 查看你的ruby源
$gem sources -l
我的返回的是我以前安装的源
*** CURRENT SOURCES ***
https://ruby.taobao.org/
以前就是用的淘宝的,但是后面的改了,所以我就改了一个源。首先删除原来的源。
gem sources --remove https://ruby.taobao.org/
执行命令后:
https://ruby.taobao.org/ removed from sources
接下来就要添加可用的镜像源
$ gem sources -a http://rubygems-china.oss.aliyuncs.com
执行命令后:
http://rubygems-china.oss.aliyuncs.com added to sources
此时就可以安装cocoapods
$ sudo gem install cocoapods
但是我这里出现了问题如下:
Fetching: gh_inspector-1.0.2.gem (100%)
Successfully installed gh_inspector-1.0.2
Fetching: fourflusher-2.0.1.gem (100%)
Successfully installed fourflusher-2.0.1
Fetching: xcodeproj-1.3.3.gem (100%)
ERROR:While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj
瞬间懵逼,不是说好的可以的吗?怎么还出错,于是自行百度,需要修改下命令,其实就是放到安装目录下去
$ sudo gem install -n /usr/local/bin cocoapods
此刻执行完后会出现
Successfully installed xcodeproj-1.3.3
Fetching: molinillo-0.5.1.gem (100%)
Successfully installed molinillo-0.5.1
Fetching: cocoapods-trunk-1.1.1.gem (100%)
Successfully installed cocoapods-trunk-1.1.1
Fetching: cocoapods-downloader-1.1.2.gem (100%)
Successfully installed cocoapods-downloader-1.1.2
Fetching: cocoapods-deintegrate-1.0.1.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.1
Fetching: cocoapods-core-1.1.1.gem (100%)
Successfully installed cocoapods-core-1.1.1
Fetching: cocoapods-1.1.1.gem (100%)
Successfully installed cocoapods-1.1.1
Parsing documentation for xcodeproj-1.3.3
Installing ri documentation for xcodeproj-1.3.3
Parsing documentation for molinillo-0.5.1
Installing ri documentation for molinillo-0.5.1
Parsing documentation for cocoapods-trunk-1.1.1
Installing ri documentation for cocoapods-trunk-1.1.1
Parsing documentation for cocoapods-downloader-1.1.2
Installing ri documentation for cocoapods-downloader-1.1.2
Parsing documentation for cocoapods-deintegrate-1.0.1
Installing ri documentation for cocoapods-deintegrate-1.0.1
Parsing documentation for cocoapods-core-1.1.1
Installing ri documentation for cocoapods-core-1.1.1
Parsing documentation for cocoapods-1.1.1
Installing ri documentation for cocoapods-1.1.1
7 gems installed
此时安装成功了,赶快去试试你的cocoapods吧
$ pod search AFN(搜索AFN)就会出现很多相关的第三方库。
是否解决了你的问题了呢?有的话就留言吧!😄