1.CocoaPods是什么?
CocoaPods是一个可以帮你集中管理第三方库的开源项目,运行在Ruby的环境下,基于GitHub托管优势,使用CocoaPods可以省去第三方类库大部分的配置和部署时间,也可以由CocoaPods直接更新第三方类库的版本.
2. 安装Cocoapods:
1.mac 升级ruby版本
1.查看当前ruby版本: ruby -v ,如果没有ruby版本先安装rvm管理下载安装 curl -L https://get.rvm.io | bash -s stable
安装问题
在防火墙已关闭的情况下使用curl-L get.rvm.io | bash -s stable出现
出现此问题需要在 /etc/hosts文件加入以下两个端口域名,即可解决
20.205.243.168 api.github.com
185.199.108.133 raw.githubusercontent.com
如果出现 curl: (35) SSL connect error 错误,使用 yum -y update nss 更新 nss 即可解决
HomeBrew安装
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
2.列出已知ruby的版本: rvm list known
3.安装版本号:rvm install 2.4.0(版本号)
1.打开终端,输入命令 $ sudo gem install cocoapods
$ sudo gem update--system 更新 gem版本的问题,直接运行
$ gem sources --remove https://rubygems.org/
//淘宝镜像现在是https:
$ gem sources --add https://gems.ruby-china.com/
//命令查看ruby镜像是否被设置成淘宝了:
$ gem sources -l
##手动安装rvm
// 离线包
curl -sSL https://github.com/rvm/rvm/tarball/stable -o rvm-stable.tar.gz
// 创建文件夹
mkdir rvm && cd rvm
// 解包
tar --strip-components=1 -xzf ../rvm-stable.tar.gz
// 安装
./install --auto-dotfiles
// 加载
source ~/.rvm/scripts/rvm
// if --path was specified when instaling rvm, use the specified path rather than '~/.rvm'
##rvm 安装 ruby
// 查询 ruby的版本
rvm list known
// 下载指定的版本
rvm install 2.4.0
// 将系统的ruby切换为下载的版本
rvm use 2.4.0 --default
————————————————
版权声明:本文为CSDN博主「humbert、」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhujianfeng123567/java/article/details/105765283
3.创建PodFile文件
切换到项目文件目录下
$ cd /Users/xy/Desktop/CocoapodsTest//项目文件的目录
$ touch Podfile
4. 编辑Podfile
1.直接打开空白的Podfile文件输入第三方库的信息,然后保存退出。
2.用命令编辑
platform :ios, '8.0'
target ‘selfProject’ do
inhibit_all_warnings!
pod 'AFNetworking'
pod 'SVGAPlayer'
end
3.$ cd进入demo的工程文件下(和Podfile在同一目录下)
4. 执行命令` $ pod install
5.更新所有的类库,获取最新版本的类库
$ pod update
//按照podfile的要求来请求类库,如果类库版本号有变化,那么将获取失败。
$ pod install
先用`$ pod update`,再用`$ pod install`就成功了
6.删除类库
1. 删除pod加入的第三方。在Podfile文件中,删除库的哪一行配置。然后重新install就可以了。
7.Mac未安装Homebrew
1.解决方法:在命令行输入以下指令安装Homebrew或者进入官网找到最新的下载链接
Homebrew官网:http://brew.sh/index_zh-cn.html
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"