美文网首页IOS开发资料库CocoaPodsios开发
CocoaPods最新安装和问题解决教程(干货)

CocoaPods最新安装和问题解决教程(干货)

作者: 十方树 | 来源:发表于2016-06-10 13:09 被阅读21932次

    CocoaPods是什么不多说,自己网上去查。今天主要讲CocoaPods的安装问题:

    1.(这是原来的,请看下面的更新)首先用淘宝的Ruby镜像来访问CocoaPods,打开终端输入以下命令:

    (1)gem sources --remove http://ruby.taobao.org/

    (2)gem sources -a https://ruby.taobao.org/

    (3)gem sources -l

    更新:淘宝源不能用了,可以用Ruby China 社区专注维护的这个源(https://gems.ruby-china.org/ )。

    首先,执行以下命令删除原来的ruby源:

    gem sources --remove https://rubygems.org/

    执行命令后可在终端看见以下信息:

    https://rubygems.org/ removed from sources

    然后下一步添加你找到的可用的镜像源:

    gem sources -a https://gems.ruby-china.org/

    验证新源是否替换成功:

    gem sources -l

    只有在终端中出现下面文字才表明你上面的命令是成功的:

    *** CURRENT SOURCES ***

    2.更新升级gem,如果它的版本过低也可能导致安装失败,在终端输入以下命令:

    sudo gem update --system

    3.安装CocoaPods:

    OS X 10.11以前,在终端输入以下命令:

    sudo gem install cocoapods

    OS X 10.11以后,在终端输入以下命令:

    sudo gem install -n /usr/local/bin cocoapods

    4.初始化:

    在终端输入以下命令:

    pod setup

    问题最多的就是这一步,第一次安装完成可能要一个小时左右,所以要耐心等待,如果这一步完成了,那么恭喜你已经成功安装了CocoaPods。想知道自己有没有安装完成,可以在终端输入以下命令:

    pod --version

    显示出版本就说明成功了。

    5.问题梳理:

    (1)在终端输入以下命令:

    pod repo list

    结果为0 repos时说明安装不成功,自己可以查看下自己的安装步骤,看看是哪一步出现了问题。

    (2)出现以下错误:

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

    Operation not permitted - /usr/bin/xcodeproj

    在网上寻找的解决方法:

    在终端中输入:sudo nvram boot-args="rootless=0"; sudo reboot

    然后你的电脑会重启

    之后再输入sudo gem install cocoapods -V

    就可以了。

    (3)pod setup时出现以下错误:

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

    Cloning into 'master'...

    error: RPC failed; curl 56 SSLRead() return error -36

    fatal: The remote end hung up unexpectedly

    fatal: early EOF

    fatal: index-pack failed

    You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.

    自己按照提示在终端输入以下命令:

    pod repo add master https://github.com/CocoaPods/Specs.git

    还是报错!

    在网上查到的解决办法:在终端输入以下命令:

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

    后面的地址你可以打开Xcode显示包内容,找到那个文件夹拖到终端里面。

    (4)试过以上所有解决办法,还是没有安装成功:

    重新安装(其实我就是这样安装成功的):

    首先,删除.cocoapods目录,在终端输入以下命令:

    sudo rm -rf ~/.cocoapods/

    然后,重新下载安装,在终端输入以下命令:

    pod setup

    ps:很多人说这两句解决了他们的问题

    $ sudo gem install -n /usr/local/bin cocoapods

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

    相关文章

      网友评论

      • eac6ebd56d25:没错 很全! 最后一个命令救了我~!:smile:
      • Bearger:咱刚试了好多方法,各种无解~!
        最后,手机4G开共享网络!分分钟搞定~!有流量就是任性~!😄

        Setting up CocoaPods master repo
        $ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
        Cloning into 'master'...
        remote: Counting objects: 1119527, done.
        remote: Compressing objects: 100% (207/207), done.
        remote: Total 1119527 (delta 98), reused 1 (delta 1), pack-reused 1119306
        Receiving objects: 100% (1119527/1119527), 381.99 MiB | 1.03 MiB/s, done.
        Resolving deltas: 100% (524530/524530), done.
        Checking out files: 100% (140762/140762), done.

        CocoaPods 1.2.1.beta.1 is available.
        To update use: `sudo gem install cocoapods --pre`
        [!] This is a test version we'd love you to try.

        For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.2.1.beta.1

        Setup completed
        a90a147abe6d:我也是开移动4g好的!好神奇~
      • ahyufei:[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress

        Cloning into 'master'...
        remote: Counting objects: 1117753, done.
        remote: Compressing objects: 100% (75/75), done.
        error: RPC failed; curl 56 SSLRead() return error -98060 KiB/s
        fatal: The remote end hung up unexpectedly
        fatal: early EOF
        fatal: index-pack failed
        我的报这样错误,还没搞定,楼主给看看哈
        十方树:@ahmgdt 这个问题经常出现,上面有说解决方案,还有可以在终端输入这两条命令 $ sudo gem install -n /usr/local/bin cocoapods
$ Git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
        ahyufei:@十方树 然而每次都是这样的问题,翻墙和不翻墙结果都一样,快崩溃了
        十方树:@ahmgdt 重新pod setup
      • 5f349a0901e0:请教一下:我在输入 sudo gem install -n /usr/local/bin cocoapods的时候,会提示输入密码,然后输出了一堆证书错误,但结果好像有安装成功了。我的已经替换了成了https://gems.ruby-china.org/。

        错误如下:
        jerdeMacBook-Pro:~ jer$ sudo gem install -n /usr/local/bin cocoapods
        Password:
        ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)
        ERROR: You must add /O=Digital Signature Trust Co./CN=DST Root CA X3 to your local trusted store
        ERROR: SSL verification error at depth 2: self signed certificate in certificate chain (19)
        ERROR: Root certificate is not trusted (/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA)
        Successfully installed cocoapods-1.1.1
        Parsing documentation for cocoapods-1.1.1
        1 gem installed
        5f349a0901e0:@十方树 显示 1.1.1 ,应该是装成功了,但是 pod setup的时候一直报错


        [!] /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

        ,还有您说主要原因是Ruby环境需要2.2以上,我用gem -v查看了输出 2.6.8,我的版本也是ok的啊
        十方树:终端输入pod --version 看有没有安装成功
        十方树:@5f349a0901e0 出现这个问题的原因主要是Ruby环境需要2.2版本以上,所以要更新Ruby环境
      • EmptyWalker:我的就是删除了安装一遍还是不行,继续报错curl: (56) SSLRead() return error -36 :sweat:
        路有点颠簸:$ sudo gem install -n /usr/local/bin cocoapods
        $ Git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
        这两句有用,转载表示感谢
        EmptyWalker:@十方树 这个方法试过了,不行,我换成了手动添加,先完成任务再说
        十方树:@EmptyWalker 有时候是网络的问题,这个是和你一样的错误,可以参考下http://blog.csdn.net/wm9028/article/details/51840759
      • 遥遥i:删除了重装都不行,绝望,各种方法装了一周了
        遥遥i:@kidskin 好了
        db88b0763026:@遥遥i 现在弄好了吗?
      • 木子F:很好,很全 :+1:
        十方树:@木子F 谢谢,现在安装好像坑越来越多。
      • caiteru:terencedeMacBook-Pro:~ Terence$ pod setup
        Setting up CocoaPods master repo
        Updating 5c0af14..04d7c83
        Fast-forward
        .../0.2.9/MAGComfortTextInput.podspec.json | 28 ++++++++++++++++++++++
        1 file changed, 28 insertions(+)
        create mode 100644 Specs/d/a/0/MAGComfortTextInput/0.2.9/MAGComfortTextInput.podspec.json
        From https://github.com/CocoaPods/Specs
        5c0af14..04d7c83 master -> origin/master
        [!] The `master` repo requires CocoaPods 1.0.0 - (currently using 0.39.0)
        Update CocoaPods, or checkout the appropriate tag in the repo.
        terencedeMacBook-Pro:~ Terence$

        你好,我想依旧用0.39的cocoapods,请问要怎么设置了,安装了0.39的cocoapods,setup的时候依旧提示[!] The `master` repo requires CocoaPods 1.0.0 - (currently using 0.39.0)
        十方树:@caiteru 你cocoaPods安装好了吗?安装好了想用低版本的降级就可以了
        十方树:@caiteru 降级就好
      • 木子影:RPC failed; curl 56 SSLRead() return error -9806 大侠知道报这个错误为什么呢
        十方树:@木子影 :+1:
        木子影:@十方树 昨晚终于装好了,谢了,大兄弟
        十方树:@木子影 网络问题,可能是网络不稳定,看下面评论,说不定能帮到你。
      • 王小祺:MacBook-Pro:~ wang$ pod setup
        Setting up CocoaPods master repo
        [!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master

        Cloning into 'master'...
        fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': SSLRead() return error -9806
        MacBook-Pro:~ wang$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
        Password:
        MacBook-Pro:~ wang$ 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

        MacBook-Pro:~ wang$ sudo rm -rf ~/.cocoapods/
        Password:
        MacBook-Pro:~ wang$ pod setup
        Setting up CocoaPods master repo
        [!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master

        Cloning into 'master'...
        fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': SSLRead() return error -9806

        MacBook-Pro:~ wang$
        大神 我这是什么情况 为什么还不行呢 :sob:
        看不到我OoO看不到我:@王小祺 你好,网络怎样会造成这样,是不是换一个网络就好了
        十方树:@王小祺 :+1:
        王小祺:@王小祺 最后发现是网络的问题,已搞定
      • Liusr:sudo gem update --system这个命令不行了
      • Liusr:目前10.11 大家的gem怎么升级的,还是报权限错误
        小唐羽锋:@SmileLiusr 我最近重新配置CocoaPods,这个命令可以用啊sudo gem update --system
        Liusr:@小唐羽锋 当时试的时候已经不行了
        小唐羽锋:@SmileLiusr sudo 管理员权限不行吗
      • light_of_king:而且不需要CD到目录下
      • light_of_king:删除目录的命令是错的,rm前面没有-
      • LLVKS:目测删除是最好的方法了
      • 熹微_____:试了您的方法 可是还是报那个错 请问您知道是什么原因吗
        9e72b5a52cd1:@十方树 请问一下通过sudo rm -rf ~/.cocoapods/指令就删除cocoapods ,再pod setup指的是卸载重装吗?打扰了
        马铃薯蜀黍:@十方树 目录在哪里呀 大神...
        十方树:删除目录,重新安装。

      本文标题:CocoaPods最新安装和问题解决教程(干货)

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