cocoapods安装(2018)

版权声明:本文为博主原创文章,欢迎转载。 https://blog.csdn.net/chen12302asd/article/details/82107693

之前做iOS开发使用cocoapods来管理第三方库,现在电脑没有安装cocoapods,需要自己安装。
今天花了点时间来安装cocoapods,总结一下cocoapods的安装过程,以后需要可以随时查看。

安装环境:
电脑版本:10.13.6 (17G65)
Xcode版本:Version 9.2 (9C40b)

更换源

删除源

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

添加源

  1. https://ruby.taobao.org/
  2. https://gems.ruby-china.org/
  3. https://gems.ruby-china.com/
gem sources -a https://gems.ruby-china.com/

安装cocoapods

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

安装cocoapods

setup

pod setup

set up

等待一段时间就好了,pod 的使用很简单,就不介绍了。
关于添加源,最先使用的是第一个taobao的,后来使用的是第二个域名org的源,现在使用的是域名com的源。

过了一会出现了下面的错误:

Setting up CocoaPods master repo
  $ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
  Cloning into 'master'...
  remote: Counting objects: 2380325, done.        
  remote: Compressing objects: 100% (304/304), done.        
  error: RPC failed; curl 18 transfer closed with outstanding read data remaining
  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: 2380325, done.        
remote: Compressing objects: 100% (304/304), done.        
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

再次执行pod setup出错。

sfit-macmini-for-test:~ user$ pod setup
Setting up CocoaPods master repo
  $ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
  Cloning into 'master'...
^Z
[3]+  Stopped                 pod setup
sfit-macmini-for-test:~ user$ 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/user/.cocoapods/repos/master fetch origin --progress
  remote: Counting objects: 2330909, done.        
  remote: Compressing objects: 100% (333/333), done.    

使用了下面的命令成功安装。

sfit-macmini-for-test:demo0827 user$ pod repo remove master
Removing spec repo `master`
sfit-macmini-for-test:demo0827 user$ 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: 2380487, done.        
  remote: Compressing objects: 100% (460/460), done.        
  remote: Total 2380487 (delta 233), reused 35 (delta 35), pack-reused 2379982        
  Receiving objects: 100% (2380487/2380487), 565.04 MiB | 271.00 KiB/s, done.
  Resolving deltas: 100% (1378034/1378034), done.
  Checking out files: 100% (261509/261509), done.

CocoaPods 1.6.0.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.6.0.beta.1

Setup completed
sfit-macmini-for-test:demo0827 user$ 

https://ruby.taobao.org

https://ruby.taobao.org/

https://gems.ruby-china.org

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

查看网站就知道这些修改了。
终于安装成功了,可以使用cocoapods来管理第三方库了。自己也可以写个开源库让别人下载使用。

猜你喜欢

转载自blog.csdn.net/chen12302asd/article/details/82107693