报错
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
进入https://gems.ruby-china网站看到
$ gem update --system # 这里请翻墙一下
$ gem -v
2.6.3
之前是https://gems.ruby-china.org/
$ gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
$ gem sources -l
https://gems.ruby-china.com
# 确保只有 gems.ruby-china.com
//安装cocoapods
sudo gem install cocoapods
报错
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj
改为
sudo gem install -n /usr/local/bin cocoapods
可以通过pod --version查看你当前的CocoaPods版本号。
指定安装cocoapods版本
sudo gem install cocoapods -v 0.34.4
pod --version 输出 0.34.4
更新时候出现的问题
1
fatal: Not a git repository (or any of the parent directories): .git
屏幕快照 2018-11-07 下午6.47.00.png
解决 终端直接输入git init
$ git init
2
CocoaPods was not able to update the master
repo.if it is a unexpected issue and persists you can inspect it running 'pod repo update --verbose'
解决 终端输入
$ sudo rm -fr ~/.cocoapods/repos/master
$ pod setup
$ pod search afnetworking
上边不行的话
还不行的话就把当前 Pods 目录清空:
$ sudo rm -fr Pods/
$ pod setup
$ pod search afnetworking
3
[!] Unable to find a pod with name, author, summary, or description matching AFNetworking
解决
$ pod setup
$ rm ~/Library/Caches/CocoaPods/search_index.json
$ pod search AFNetworking
应该就会好了
打印终端输入的历史信息
$ history
操作
操作:
1.右键点击工程文件,打开方式终端
2.输入 cd ..
3.输入 touch Podfile (文件夹里面会出现一个Podfile文
4.pod search AFNetworking
5.将搜索结果复制到 3步 多出来的白色文件中,把想添加的第三方文件添加进去,例如:pod 'AFNetworking'
6终端输入 pod install --verbose --no-repo-update
pod update --verbose --no-repo-update
最新版本 pod update
导入第三方 pod install 用这个
Podfile文件的固定格式
platform :ios, '8.0'
use_frameworks!
target '项目名称' do
pod 'AFNetworking'
end
查看项目已经添加的三方历史版本号
直接把Podfile.lock后缀改成Podfile.txt查看
屏幕快照 2018-11-08 下午12.29.59.png
pod search 报错
myhqMacdeMBP:~ myhqmac$ pod search AFNetworking
[!] CDN: trunk Repo update failed - 2 error(s):
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/c/5/6/DCNetworkReactor/1.0.0/DCNetworkReactor.podspec.json, error: Failed to open TCP connection to raw.githubusercontent.com:443 (Connection refused - connect(2) for "raw.githubusercontent.com" port 443)
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/c/5/6/DCNetworkReactor/1.0.1/DCNetworkReactor.podspec.json, error: Failed to open TCP connection to raw.githubusercontent.com:443 (Connection refused - connect(2) for "raw.githubusercontent.com" port 443)
myhqMacdeMBP:~ myhqmac$ pod repo remove trunk
Removing spec repo `trunk`
myhqMacdeMBP:~ myhqmac$ pod search AFNetworking
执行
pod repo remove trunk
截屏2019-12-18下午8.42.14.png
网友评论