// brew 安装cocoapods
brew reinstall cocoapods
brew link --overwrite cocoapods
// 没有查到适合系统的版本时会提示下边的安装指令
brew install --build-from-source cocoapods
brew reinstall --build-from-source cocoapods
// gem安装cocoapods
sudo gem install -n /usr/local/bin cocoapods
// 卸载
sudo gem uninstall cocoapods -n /usr/local/bin
// 查询安装的依赖
gem list --local | grep cocoapods
// 卸载依赖
sudo gem uninstall cocoapods
sudo gem uninstall cocoapods-core
sudo gem uninstall cocoapods-deintegrate
sudo gem uninstall cocoapods-downloader
sudo gem uninstall cocoapods-plugins
sudo gem uninstall cocoapods-search
sudo gem uninstall cocoapods-trunk
sudo gem uninstall cocoapods-try
// 项目命令 clone的flutter在~/flutter/
cd shero/
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/flutter/bin
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
flutter create -t module --org SheroFlutter SheroFlutter
cd SheroFlutter
flutter pub get
cd ..
rm -rf Podfile.lock
pod install
安装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 gem uninstall cocoapods -n /usr/local/bin
// brew 重装 cocoapods
brew reinstall cocoapods
brew link --overwrite cocoapods
// 清除本地的索引库
sudo rm -fr ~/.cocoapods/repos/master
pod setup执行慢的解决思路
cd ~/.cocoapods/repos
再 git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master1
删除 master1 中的.git 文件夹
移动 原有master 的.git 文件夹到master1文件夹(没有master就pod setup 一会再取消)
删除master
重命名master1为master
查找框架
pod search AFNetworking
// 工程目录下创建Podfile
pod init 自动创建Podfile //手动 touch Podfile
// 内容格式
platform :ios, "8.0" 8.0代表兼容的ios版本 不指定会用最新的框架
pod 'SVProgressHUD' 框架名用'' 或者""都行
pod 'JSONKit', '~> 1.4' 不指定版本,默认下载最新版
#使用本地文件
pod 'AFNetworking', :path => '~/Documents/AFNetworking'
#使用仓库中的master分支(使用默认仓库地址时可以不用指定:git)
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git'
#使用仓库的其他分支(使用默认仓库地址时可以不用指定:git)
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :branch => 'dev'
#使用仓库的某个tag(使用默认仓库地址时可以不用指定:git)
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :tag => '0.7.0'
#指定一个提交记录(使用默认仓库地址时可以不用指定:git)
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :commit => '082f8319af'
初次下载使用
pod install --no-repo-update
修改后更新用(如果不加--no-repo-update会更新依赖库到最新版本)
pod update --no-repo-update 也可以pod install 不会更新本地
更新本地框架库
pod repo update
pod repo update --verbose 可以查看详细信息
不集成到工程,只下载
pod install --no-integrate
可以查看详细信息,看看卡到哪一步了,下载速度之类
pod install --verbose
用gem查看pods的版本有哪些
gem list
安装指定版本
sudo gem install -n /usr/local/bin cocoapods -v (版本号)
安装最新版本
sudo gem install -n /usr/local/bin cocoapods --pre
移除当前的pod版本
sudo gem uninstall cocoapods -v (移除的版本号)
/// 报错可以试试 sudo gem uninstall cocoapods -n /usr/local/bin
查看本地安装过的cocopods相关东西
gem list --local | grep cocoapods
然后使用命令逐个删除
sudo gem uninstall ****
--pod install 报错: can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
Traceback (most recent call last):
2: from /usr/local/bin/pod:23:in `<main>'
1: from /Library/Ruby/Site/2.6.0/rubygems.rb:294:in `activate_bin_path'
/Library/Ruby/Site/2.6.0/rubygems.rb:275:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
重新安装 ruby 环境(默认安装最新版本)
rvm reinstall ruby --disable-binary
在安装最新版本cocoapods
sudo gem install -n /usr/local/bin cocoapods --pre
1. Ignoring bigdecimal-1.3.5 because its extensions are not built. Try: gem pristine bigdecimal --version 1.3.5
gem uninstall bigdecimal
gem install bigdecimal
或者
sudo gem install bigdecimal -v 1.3.5
2. kernel_require.rb:54:in `require': incompatible library version - /Users/shmily/.rvm/gems/ruby-2.3.0/gems/psych-3.0.2/lib/psych.bundle (fatal)
sudo gem uninstall psych
sudo gem install psych
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换源
库索引目录
cd ~/.cocoapods/repos/master/Specs
find * -name 'hermes-engine'
find * -name 'YogaKit'
find * -name 'glog'
库名字md5的前三位 是库所在的子文件夹路径
echo -n "glog"|md5
echo -n "hermes-engine"|md5
库缓存目录
~/Library/Caches/CocoaPods/Pods/Specs/Release
~/Library/Caches/CocoaPods/Pods/Release
针对于 Release 库的名字规则 aaaaa = shasum -a 1 json文件
~/Library/Caches/CocoaPods/Pods/Release/三方库/版本号-aaaaa.podspec.json