CocoaPods的安装步骤和遇见的问题
2015-09-25 本文已影响185人
CoderShmily
安装cocoapods
建议先更新下gem
sudo gem update --system
gem sources --remove https://rubygems.org/
// gem sources -a https://ruby.taobao.org/ 这个源也不行了
gem sources -a https://gems.ruby-china.org/
gem sources -l
// 新版本要有问题试试
// sudo gem install cocoapods应该会提示下错误
// ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/update_rubygems
试试 gem update -n /usr/local/bin --system
// 安装cocoapods
sudo gem install -n /usr/local/bin cocoapods
pod repo list // 查看repo 列表
pod repo remove master // 删除master
新版的 CocoaPods 不允许用pod repo add直接添加master库了,现在一般执行完pod repo add master *** 之后又会提示[!] To setup the master specs repo, please run pod setup.但是依然可以:
// https://mirrors.tuna.tsinghua.edu.cn/help/CocoaPods/ 清华大学的CocoaPods 镜像
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git ~/.cocoapods/repos/master
// 默认的 https://github.com/CocoaPods/Specs.git
// 备用的 git://cocoapodscn.com/Specs.git
在自己工程的podFile第一行加上:刚刚替换的新repo
// source 'git://cocoapodscn.com/Specs.git'
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
// cd ~/.cocoapods然后下面指令
// du -sh * 查看下载进度
// pod setup手动克隆就不要执行这个了,不然一会又要死循环了
pod --version
卸载CocoaPods
sudo gem uninstall cocoapods
// 清除本地的索引库
sudo rm -fr ~/.cocoapods/repos/master
查找框架
pod search AFNetworking
// 工程目录下创建Podfile
pod init 自动创建Podfile //手动 touch Podfile
// 内容格式
platform :ios, "8.0" 8.0代表兼容的ios版本 不指定会用最新的框架
pod 'SVProgressHUD' 框架名用'' 或者""都行
pod 'JSONKit', '~> 1.4' 不指定版本,默认下载最新版
platform :ios, "8.0"
pod 'Masonry'
初次下载使用
pod install --no-repo-update
修改后更新用(如果不加--no-repo-update会更新依赖库到最新版本)
pod update --no-repo-update 也可以pod install 不会更新本地
更新本地框架库
pod repo update
不集成到工程,只下载
pod install --no-integrate
可以查看详细信息,看看卡到哪一步了,下载速度之类
pod install --verbose
1. 如果提示关于gem的东西找不到:
sudo gem uninstall --all
sudo gem install cocoapods
2. brew update失败可以用 /usr/local/bin/brew update --force
3. 执行sudo gem install cocoapods的时候提示错误
ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR: You must add /C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Certification Authority 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)
其实只要是使用gem的都会又ssl证书问题。 下面说下用的新路径
gem sources --remove https://ruby.taobao.org/
gem sources -a https://gems.ruby-china.com
// 备用 http://rubygems-china.oss.aliyuncs.com
gem sources -l
sudo gem install -n /usr/local/bin cocoapods
然后就会执行成功了,不过此刻会卡住,其实是在下载文件,你可以用下面的方法查看下载的文件大小。
cd ~/.cocoapods/
du -sh *
到此就可以说是解决了这个问题了。
4. [!] Unable to find a pod with name, author, summary, or description matching `AFNetworking`
解决:rm ~/Library/Caches/CocoaPods/search_index.json
5. [!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
重新设置代理 git config --global http.proxy
取消代理 git config --global --unset http.proxy
然后在pod setup
6. $ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
把翻墙软件关了再试试
7. $ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
进工程里面 pod install
8. $ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master`.
You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.
先添加repo,pod repo add master https://github.com/CocoaPods/Specs.git
提示后提示执行’pod setup’,执行 sudo rm -fr ~/.cocoapods/repos/master
在 pod setup
9. error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
设置 git config --global http.postBuffer 524288000 或者更大114288000
10. pod install 时出现
[!] Error installing *****
[!] /usr/bin/git clone https://github.com/rs/SDWebImage.git /var/folders/8z/_9cm1zvj7q738hyzp1gr4wr00000gr/T/d20180725-49499-1u9kd9 --template= --single-branch --depth 1 --branch 3.7.6
Cloning into '/var/folders/8z/_9cm1zvj7q738hyzp1gr4wr00000gr/T/d20180725-49499-1u9kd9'...
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: unpack-objects failed
1.创建临时环境变量:env GIT_SSL_NO_VERIFY=true git clone ...
2.用git自带的配置命令:git config --global http.sslVerify false
11. 加快git clone 几十倍速度的小方法
修改host文件: /etc/hosts
151.101.72.249 github.global.ssl.fastly.net
192.30.253.112 github.com
1.解决CocoaPods各种慢的方案(gem换源+pod repo换源)
2.安装cocopods遇到新问题
3.cocoapods安装好后repo换源