M1 cocoaPods安装
一、CocoaPods的简介与好处
简介:CocoaPods是OS X和iOS下的一个第三类库管理工具,通过CocoaPods工具我们可以为项目添加被称为“Pods”的依赖库(这些类库必须是CocoaPods本身所支持的),并且可以轻松管理其版本。
优点:
1、在引入第三方库时它可以自动为我们完成各种各样的配置,包括配置编译阶段、连接器选项、甚至是ARC环境下的-fno-objc-arc配置等。
2、使用CocoaPods可以很方便地查找新的第三方库,这些类库是比较“标准的”,而不是网上随便找到的,这样可以让我们找到真正好用的类库
二、Cocoapods安装步骤
1、查看当前Ruby版本
ruby -v
2、升级Ruby环境,首先需要安装rvm
curl -L get.rvm.io | bash -s stable
source ~/.bashrc
source ~/.bash_profile
3、查看rvm版本
显示 rvm 1.29.3(latest)by Michal Papis,Piotr Kuczynski,Wayne E. Seguin [https://rvm.io]
4、列出ruby可安装的版本信息
rvm list known
显示如下:
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.6]
[ruby-]2.5[.5]
[ruby-]2.6[.3]
[ruby-]2.7[.0-preview1]
ruby-head
5.查看ruby源
gem sources -l
结果是如下则直接按转cocoaPods
***CURRENT SOURCES***https://gems.ruby-china.com/
如果不是 https://gems.ruby-china.com/
6.更换ruby源
sudo gem update--systemgem sources--removehttps://rubygems.org/gem sources--addhttps://gems.ruby-china.com/
7、我们来开始安装CocoaPods
安装成功后显示
Fetching httpclient-2.8.3.gemFetching algoliasearch-1.27.1.gemFetching cocoapods-core-1.8.3.gemFetching cocoapods-trunk-1.4.1.gemFetching xcodeproj-1.12.0.gemFetching cocoapods-1.8.3.gemSuccessfully installed httpclient-2.8.3Successfully installed algoliasearch-1.27.1Successfully installed cocoapods-core-1.8.3Successfully installed cocoapods-trunk-1.4.1Successfully installed xcodeproj-1.12.0Successfully installed cocoapods-1.8.3Parsing documentation for httpclient-2.8.3Installing ri documentation for httpclient-2.8.3Parsing documentation for algoliasearch-1.27.1Installing ri documentation for algoliasearch-1.27.1Parsing documentation for cocoapods-core-1.8.3Installing ri documentation for cocoapods-core-1.8.3Parsing documentation for cocoapods-trunk-1.4.1Installing ri documentation for cocoapods-trunk-1.4.1Parsing documentation for xcodeproj-1.12.0Installing ri documentation for xcodeproj-1.12.0Parsing documentation for cocoapods-1.8.3Installing ri documentation for cocoapods-1.8.3Done installing documentation for httpclient,algoliasearch,cocoapods-core,cocoapods-trunk,xcodeproj,cocoapods after 14 seconds6 gems installed
8、再安装本地库
pod setup
执行以上命令后会显示
Setting up CocoaPods master repo
$ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
remote: Counting objects: 1879515, done.
remote: Compressing objects: 100% (321/321), done.
Receiving objects: 21% (404525/1879515), 73.70 MiB | 22.00 KiB/
9.用pod search afnetworking检验pod是否安装成功
如果不显示则
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