美文网首页IOS开发资料库iOSiOS -- BLE之路
2017年最新cocoapods安装教程(解决淘宝镜像源无效以及

2017年最新cocoapods安装教程(解决淘宝镜像源无效以及

作者: 安勒个安 | 来源:发表于2017-01-10 18:32 被阅读5407次

最新更新:使用软件包管理工具-brew,可以直接安装cocoapods。方法:brew install cocoapods 亲测有效
brew的安装可以参考我之前的一篇文章,这是---传送门

首先,先来说一下一般的方法吧,就是把之前的淘宝源替换成一个可用的的源:

使用终端查看当前的源

gem sources -l
gem sources -r https://rubygems.org/ #删除源
gem sources -a https://gems.ruby-china.org/ #添加源

我这里有一个比较好的一个源

https://gems.ruby-china.org/

之后使用sudu gem install cocoapods 然后输入管理员密码 就可以了
但是这样有个缺点,就是下载巨慢~~有些时候网络不稳定的话还会断掉。可能运气好的人一天可以安装上,但如果你是非洲人的话。嘿嘿嘿。

这个时候,忍不住想快一点的同学就可以看过来了。

首先,我们打开终端。cd 到这个路径

cd ~/.cocoapods/repos

当然如果没有的话就自己创建一个。也可以 gem install cocoapods,当看到出现cocoapods的目录时就可以终止了。
后面,我们cd到repos文件路径没问题了之后,重点来了。

  • 方法一:
git clone https://github.com/CocoaPods/Specs

输入这个命令将cocoapods的索引文件下载下来

zip下载方式.png

使用ZIP下载的方式下载下来文件,解压到repos目录

  • 方法三:
    如果你有同事的话,找他拷贝一份~/.cocoapods/repos目录下的文件(这种方法最轻松!!)

好了,至此我们的索引文件夹就已经下载下来了,这也是网上遇到问题最多的,很费时,断网了还需要重头下载。。
最关键的一步来了。我们下载的这份名为Specs的文件夹需要改名为master,并且需要注意的是,它必须是在放在~/.cocoapods/repos这个路径下面的。如果不对请放好了再来。

将Specs文件夹重命名为master.png

之后 只需要cd ~/.cocoapods/repos/master路径,执行一步

git init

将git初始化一下,完成!至此你的电脑上已经能够正常使用cocoapods了。

说起来麻烦,其实操作起来很简单。这也是看了网上很多教程并没有最新的之后才写上去的。如果有什么问题,欢迎指出。谢谢观看

相关文章

网友评论

  • 金___k:写的有问题 我和上面2个一样的错 改成master之后 就没下一步了
    金___k:@安勒个安 没看见 有地址吗?
    安勒个安:看我最新的更新啊亲,我都已经不用之前写的这种方法了- -
  • fanzq_jianshu:从githud采用方案二操作,pod版本有了,是1.2.0;但是pod update等正常代码都用不了。提示:

    pod update提示错误:
    [!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master-1`.
    You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.

    pod setup提示错误:
    [!] CocoaPods was not able to update the `master` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`

    pod search提示错误:
    [!] Unable to find a pod with name, author, summary, or description matching `AFN`
    fanzq_jianshu:@安勒个安 如果是仅仅创建空白仓库,对config文件进行以下配置:[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
    [remote "origin"]
    url = https://github.com/CocoaPods/Specs.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
    remote = origin
    merge = refs/heads/master

    输入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/fzq/.cocoapods/repos/master fetch origin
    fanzq_jianshu:@安勒个安 下载后的文件夹名字是Specs-master,改成master了。放在repo文件夹下
    安勒个安:@fanzq_jianshu 你把文件夹名字改了吗?他是说找不到你的库啊
  • 白云之巅1992:你好 请问 git init 是在哪个文件夹下执行的?
    安勒个安:@前年的邂逅_Jerry 。。你还是直接拉你项目路径吧
    前年的邂逅_Jerry:具体在哪个目标文件夹下
    安勒个安:@赵宪云 当然是要移动到目标文件夹下面。

本文标题:2017年最新cocoapods安装教程(解决淘宝镜像源无效以及

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