- 查看Mac使用的是哪种源,可以用gem sources -l 命令
- 查看rvm的版本:rvm -v , 查看ruby的版本:ruby -v
- 查看rvm所支持的ruby的版本:rvm list known
- 更新rvm : rvm get stable
- 更新ruby到某个版本(例如:2.4): rvm install 2.4
这样:rvm reinstall ruby-2.6.3 - 安装和更新pod : pod setup
- 查看pod版本:$ pod --version
- 6步骤如果出错,升级:输入命令:"sudo gem install -n /usr/local/bin cocoapods"
- 查看rvm 占用空间大小:rvm disk-usage all
- 如果rvm -v 报错:-bash: rvm: command not found,那么需要开始安装rvm,终端:curl -L https://get.rvm.io | bash -s stable;然后载入rvm环境,终端:source ~/.rvm/scripts/rvm,再试:rvm -v;
- Mac OS X 10.11前
sudo gem install cocoapods
Mac OS X 10.11后
sudo gem install -n /usr/local/bin cocoapods
输入:pod search AFNetworking,报错:Unable to find a pod with name, author, summary, or description matchingAFNetworking
,
这个时候直接去Git上拉去就好了:
git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master。
- nvm国内镜像参考: https://blog.csdn.net/win_liudan/article/details/121184013?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2aggregatepagefirst_rank_ecpm_v1~rank_v31_ecpm-3-121184013.pc_agg_new_rank&utm_term=%E5%9B%BD%E5%86%85%E5%AE%89%E8%A3%85nvm&spm=1000.2123.3001.4430
报错 一:You need at least git version 1.8.5 to use CocoaPods
问题:有一种可能是cocoapods安装成功了,但是链接Xcode的版本过低,所以需要更新Xcode。或者你电脑安装了多个版本的Xcode,就需要修改链接Xcode路径,改成链接电脑比较高版本的Xcode。
解决:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
后面的路径根据你较高版本Xcode路径修改
报错 二 :cocoapod 安装成功,一些准备好后,发现pod search的时候还是有错误:
[!] Unable to find a pod with name, author, summary, or description matching `afnetworking`
则解决:
1. 执行pod setup
其实在你安装CocoaPods执行pod install时,系统会默认操作pod setup,然而由于中国强大的墙可能会pod setup不成功。这时就需要手动执行pod setup指令,如下:
终端输入:pod setup
会出现Setting up CocoaPods master repo,稍等几十秒,最底下会输出Setup completed。说明执行pod setup成功。
如果pod search操作还是搜索失败,如下:
终端输入:pod search AFNetworking
输出:Unable to find a pod with name, author, summary, or descriptionmatching 'AFNetworking' 这时就需要继续下面的步骤了。
2. 删除~/Library/Caches/CocoaPods目录下的search_index.json文件
pod setup成功后,依然不能pod search,是因为之前你执行pod search生成了search_index.json,此时需要删掉。
终端输入:rm ~/Library/Caches/CocoaPods/search_index.json
删除成功后,再执行pod search。
3. 执行pod search
终端输入:pod search afnetworking(不区分大小写)
输出:Creating search index for spec repo 'master'.. Done!,稍等片刻······就会出现所有带有afnetworking字段的类库。
报错:Unable to find a pod with name, author, summary, or description matching `afnetworking`
1, pod repo remove master
2, cd ~/.cocoapods/repos
3, git clone --depth 1 https://github.com/CocoaPods/Specs.git master
4, rm ~/Library/Caches/CocoaPods/search_index.json
5, pod search afnetworking
pod 集成第三方:
a.vim Podfile
b.输入i ,可输入后:
platform :ios, '8.0'
target 'wgj_test1' do
pod 'MMPopupView', '1.5.3'
end
c. 点击esc,然后输入冒号,然后输入w和q
d. pod install
成功安装即可。
注意点(若报openssl的错误,安装ruby的时候需要携带openssl的路径(which openssl)):
参考一1. ./configure --with-openssl-dir=/usr/local/ssl
sudo make install
参考二2. rvm install 2.3.1 --with-openssl-dir=$HOME/.rvm/usr
gem sources -a https://ruby.taobao.org/
sudo gem install cocoapods
最后用gem install cocoapods 安装成功了。
报错:
setup过程中如果出现 error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54错误,
就执行 $ git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master 命令应该就可以了。
注意点:(更换源的命令:$ gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/)(切换镜像源:
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/),关于镜像源的改变:https://ruby-china.org/topics/29250。https://ruby.taobao.org。
-->改为:https://gems.ruby-china.com/。
HomeBrow安装: https://www.cnblogs.com/haojile/p/13193805.html
另参考:
- http://alvinhu.com/blog/2013/10/25/brew-gem-rvm-and-bundler/
-
//www.greatytc.com/p/c42f2cda860e
3.https://docs.morpheusdata.com/en/3.5.1/getting_started/cli/ruby_prerequisite.html (有关ruby) - //www.greatytc.com/p/f5591af6859d
- //www.greatytc.com/p/b24ddfb84657
- //www.greatytc.com/p/dbfdece084d5
- https://zhuanlan.zhihu.com/p/481802103