美文网首页
cocoapods的安装和使用笔记

cocoapods的安装和使用笔记

作者: FDZero | 来源:发表于2017-05-09 17:00 被阅读134次

    换了电脑,要重新安装cocoapods,中间遇到了一些问题,虽然解决了但是为了方便下一次在可能的安装使用,因此整理了整个安装过程以及问题,记录在此贴中。

    安装

    安装命令:sudo gem install cocoapods

    输入这个命令后如果长时间没有反应,那么可能是镜像源的问题,用命令:gem sources -l查看当前镜像源,如果是https://rubygems.org/那么就将其替换为https://ruby.taobao.org/,具体命令为:gem sources --remove https://rubygems.org/,gem sources -a https://ruby.taobao.org/

    然后重新执行安装命令:sudo gem install cocoapods

    此时提示我这样一个错误

    ERROR:While executing gem ... (Gem::DependencyError)

    Unable to resolve dependencies: cocoapods requires cocoapods-core (= 1.2.0), cocoapods-downloader (< 2.0, >= 1.1.3), cocoapods-trunk (< 2.0, >= 1.1.2), molinillo (~> 0.5.5), xcodeproj (< 2.0, >= 1.4.1)

    开始时我个人的解决方法是直接调用命令进行这些依赖的安装

    sudo gem install cocoapods-core

    sudo gem install cocoapods-downloader

    sudo gem install cocoapods-trunk

    sudo gem install molinillo

    这些都没有问题,成功的将依赖升级到适合的版本

    但是在最后一个sudo gem install xcodeproj的时候它又提示我新的问题

    ERROR:While executing gem ... (Gem::DependencyError)

    Unable to resolve dependencies: xcodeproj requires nanaimo (~> 0.2.3)

    我尝试用sudo gem install nanaimo去安装nanaimo则提示我

    ERROR:Could not find a valid gem 'nanaimo' (>= 0), here is why:

    Unable to download data from https://ruby.taobao.org/ - bad response Forbidden 403 (https://gems-ruby-china.b0.upaiyun.com/latest_specs.4.8.gz)

    看着意思应该是在淘宝镜像源中没有对应的nanaimo下载,镜像源除了淘宝我也不知道还有哪些,没办法,通过百度得到的解决方法是直接升级gem,也就是说不用上面的命令去安装cocoapods requires cocoapods-core (= 1.2.0), cocoapods-downloader (< 2.0, >= 1.1.3), cocoapods-trunk (< 2.0, >= 1.1.2), molinillo (~> 0.5.5), xcodeproj (< 2.0, >= 1.4.1)这些依赖,直接升级gem就可以了

    升级命令为:gem update --system

    升级过程没遇到问题,成功后在调用安装命令:sudo gem install cocoapods

    提示新的问题

    ERROR:While executing gem ... (Errno::EPERM)

    Operation not permitted - /usr/bin/xcodeproj

    没有路径权限,调用另外一条命令安装:sudo gem install -n /usr/local/bin cocoapods --pre

    整个安装过程log如下

    Successfully installed xcodeproj-1.4.4

    Fetching: ruby-macho-1.1.0.gem (100%)

    Successfully installed ruby-macho-1.1.0

    Fetching: gh_inspector-1.0.3.gem (100%)

    Successfully installed gh_inspector-1.0.3

    Fetching: fourflusher-2.0.1.gem (100%)

    Successfully installed fourflusher-2.0.1

    Fetching: escape-0.0.4.gem (100%)

    Successfully installed escape-0.0.4

    Fetching: cocoapods-try-1.1.0.gem (100%)

    Successfully installed cocoapods-try-1.1.0

    Fetching: cocoapods-trunk-1.2.0.gem (100%)

    Successfully installed cocoapods-trunk-1.2.0

    Fetching: cocoapods-stats-1.0.0.gem (100%)

    Successfully installed cocoapods-stats-1.0.0

    Fetching: cocoapods-search-1.0.0.gem (100%)

    Successfully installed cocoapods-search-1.0.0

    Fetching: cocoapods-plugins-1.0.0.gem (100%)

    Successfully installed cocoapods-plugins-1.0.0

    Fetching: cocoapods-deintegrate-1.0.1.gem (100%)

    Successfully installed cocoapods-deintegrate-1.0.1

    Fetching: cocoapods-core-1.2.1.gem (100%)

    Successfully installed cocoapods-core-1.2.1

    Fetching: cocoapods-1.2.1.gem (100%)

    Successfully installed cocoapods-1.2.1

    Parsing documentation for xcodeproj-1.4.4

    Installing ri documentation for xcodeproj-1.4.4

    Parsing documentation for ruby-macho-1.1.0

    Installing ri documentation for ruby-macho-1.1.0

    Parsing documentation for gh_inspector-1.0.3

    Installing ri documentation for gh_inspector-1.0.3

    Parsing documentation for fourflusher-2.0.1

    Installing ri documentation for fourflusher-2.0.1

    Parsing documentation for escape-0.0.4

    Installing ri documentation for escape-0.0.4

    Parsing documentation for cocoapods-try-1.1.0

    Installing ri documentation for cocoapods-try-1.1.0

    Parsing documentation for cocoapods-trunk-1.2.0

    Installing ri documentation for cocoapods-trunk-1.2.0

    Parsing documentation for cocoapods-stats-1.0.0

    Installing ri documentation for cocoapods-stats-1.0.0

    Parsing documentation for cocoapods-search-1.0.0

    Installing ri documentation for cocoapods-search-1.0.0

    Parsing documentation for cocoapods-plugins-1.0.0

    Installing ri documentation for cocoapods-plugins-1.0.0

    Parsing documentation for cocoapods-deintegrate-1.0.1

    Installing ri documentation for cocoapods-deintegrate-1.0.1

    Parsing documentation for cocoapods-core-1.2.1

    Installing ri documentation for cocoapods-core-1.2.1

    Parsing documentation for cocoapods-1.2.1

    Installing ri documentation for cocoapods-1.2.1

    13 gems installed

    成功后调用命令测试是否能够使用pod search AFNetworking

    提示

    Setting up CocoaPods master repo

    $ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress

    Cloning into 'master'...

    remote: Counting objects: 1195714, done.

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

    error: RPC failed; curl 56 SSLRead() return error -36 358.00 KiB/s

    fatal: The remote end hung up unexpectedly

    fatal: early EOF

    fatal: index-pack failed

    [!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress

    Cloning into 'master'...

    remote: Counting objects: 1195714, done.

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

    error: RPC failed; curl 56 SSLRead() return error -36 358.00 KiB/s

    fatal: The remote end hung up unexpectedly

    fatal: early EOF

    fatal: index-pack failed

    根据第一句的提示是需要setup pod,此时调用命令:pod setup

    Setting up CocoaPods master repo

    $ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress

    Cloning into 'master'...

    remote: Counting objects: 1195723, done.

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

    remote: Total 1195723 (delta 10159), reused 33 (delta 33), pack-reused 1177785

    Receiving objects: 100% (1195723/1195723), 391.28 MiB | 313.00 KiB/s, done.

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

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

    Setup completed

    这个过程没有遇到问题

    最后再次验证pod search AFNetworking

    能够显示出正确结果,说明安装成功,可以使用了

    使用(待续...)

    相关文章

      网友评论

          本文标题:cocoapods的安装和使用笔记

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