环境配置、CocoaPads更新安装问题

环境配置 首先 要注意ruby 版本 及gem 源问题

可以先下载shell 管理 工具homebrew、rwm等管理)

homebrew工具安装ruby流程https://www.jianshu.com/p/31b88efffaf9

//cocoapods 安装及自定 版本
$sudo gem install -n /usr/local/bin cocoapods (-v 1.6.1)

pod init 失败

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=%5BXcodeproj%5D+Unknown+object+version.&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

尝试更新:

终端查看版本: $ pod --version
因为很多第三方会限制cocoapods的最低版本
比如Alamofire要求cocoapods版本为1.1以上

$ sudo rm -fr ~/.cocoapods/repos/master  
$ pod setup
$ pod --version

安装:


温馨提示"$"是注释,拷贝"$"以后的命令就OK啦

1.查看ruby镜像最好更新到最新:

终端输入命令
$ ruby -v 
完成输出:ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]

版本太低需要更新一下

2.安装更新

$ gem sources -l
设置新的源
$ (sudo)gem source -a https://gems.ruby-china.com
删除源
$ sudo gem sources -r https://rubygems.org


// $ sudo gem update cocoapods (弃用)
// $  sudo gem install cocoapods

原因:在stackoverflow搜到的解释是这样的,This is happening because Apple has enabled rootless on the new install,也就是说在10.11系统上苹果已经启用无根的安装。在这种情况下,如果你使用如下的命令:
$ sudo gem install -n /usr/local/bin cocoapods

Fetching: rubygems-update-2.6.8.gem (100%)
Successfully installed rubygems-update-2.6.8
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/pod
kaiver520:pod kaiver$ 

输出:
Fetching: cocoapods-core-1.1.1.gem (100%)
Successfully installed cocoapods-core-1.1.1

3.换成清华大学master

成功之后不要急着执行pod setup,cocoapods这个项目比较大,从github上clone这个会很慢,这里直接使用国内的镜像作为master或者直接报错

$ pod setup
然后就是等啦(要很耐心的那种哦)
输出:
Setting up CocoaPods master repo
  $ /usr/bin/git -C /Users/likangwei/.cocoapods/repos/master fetch origin
  From https://github.com/CocoaPods/Specs
这时候不放心可以去目录下看看文件有没有变换
$ open ~/.cocoapods
在变就行了
输出:
Setup completed 恭喜终于搞好啦

pod install 如果报56或者54

默认缓存不够 加缓存 $git config http.postBuffer 524288000

  remote: Enumerating objects: 362, done.        
  remote: Counting objects: 100% (362/362), done.        
  remote: Compressing objects: 100% (334/334), done.        
  error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
  fatal: the remote end hung up unexpectedly
  fatal: early EOF
  fatal: index-pack failed
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master`.
You can try adding it manually in `/Users/g/.cocoapods/repos` or via `pod repo add`.

git克隆失败 大致是源问题导致

如安装homebrew 安装卡主切换源即可

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

https://www.jianshu.com/p/e70b1bbb5ec4

error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

Cloning into '/var/folders/sy/t4fx9p_567g6xdb7_prf_54h0000gn/T/d20220302-61090-en7uc4'...
fatal: unable to access 'https://github.com/matej/MBProgressHUD.git/': Failed to connect to github.com port 443: Operation timed out
Cloning into '/var/folders/3h/hh0t69t10slcb4wb5_gx8h6h0000gn/T/d20210415-976-wyjfgb'...
fatal: unable to access 'https://github.com/candyan/TencentOpenApiSDK.git/': Failed to connect to 127.0.0.1 port 1080: Connection refused

解决方案
在开启shadowsock的前提下,手动配置git的代理。git客户端输入如下两个命令就可以了。

git config --global http.proxy http://127.0.0.1:1080

git config --global https.proxy http://127.0.0.1:1080

http://也可以改成sockets5://,但是区别在于:socks5不支持通过pubkey免密登录github,每次提交代码只能输入用户名和密码。http可以支持免密登录。

取消代理:

git config --global --unset http.proxy

git config --global --unset https.proxy

安装国内镜像

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一、前言 CocoaPods is the dependency manager for Swift and Ob...
    破晓霜林阅读 1,922评论 0 7
  • CocoaPods 是什么? CocoaPods 是一个负责管理 iOS 项目中第三方开源库的工具。CocoaPo...
    朝洋阅读 25,745评论 3 50
  • 你们,前两天一定被李安在上影节论坛的发言刷屏了。 如果安叔的发言能引起你思考。 那就别错过Sir今天推荐这部老片—...
    Sir电影阅读 1,446评论 2 12
  • 你说 超人会飞 它会飞到哪儿去 飞到草原 飞到花海里 飞到有彩虹的岛屿 那它能飞到我身边吗 我在期盼 心里开出了一...
    半亩人阅读 347评论 3 1
  • 废话不多说,直接上图。 不过这样的设计,感觉好像化学课上的分子式... 作为一款试验性的产品,试图让平面性思维脑图...
    李福东阅读 739评论 9 0