安装
1、查看gem版本
gem --version (比如:2.6.8)
2、更新gem
gem update --system
3、查看数据源
gem sources
4、删除数据源
gem sources --remove https://rubygems.org/
5、 添加数据源
gem sources -a https://ruby.taobao.org/
“https://ruby.taobao.org/” 数据包的源地址
6、搜索软件包
gem search 软件包关键字
7. 安装软件包
gem install 软件包名称
8、安装上一个版本软件包
gem install cocoapods --pre
9、卸载安装包
gem uninstall 软件包名称
使用
安装完成后查看pod版本
pod --version
进入项目目录
cd ~
创建Podfile文件
touch Podfile
安装依赖库
pod install(后续添加框架可直接pod update)
Podfile配置
# 下面两行是指明依赖库的来源地址
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/Artsy/Specs.git'
# 说明平台是ios,版本是9.0
platform :ios, '9.0'
# 忽略引入库的所有警告(强迫症者的福音啊)
inhibit_all_warnings!
# 针对MyApp target引入AFNetworking
# 针对MyAppTests target引入OCMock,
target 'MyApp' do
pod 'AFNetworking', '~> 3.0'
target 'MyAppTests' do
inherit! :search_paths
pod 'OCMock', '~> 2.0.1'
end
end
# 这个是cocoapods的一些配置,官网并没有太详细的说明,一般采取默认就好了,也就是不写.
post_install do |installer|
installer.pods_project.targets.each do |target|
puts target.name
end
end
注意:
pod install 和 pod update 的区别
pod install //install project dependencies to podfile.lock version
如果Podfile.lock文件存在, 直接从此文件中读取框架信息下载安装,
如果 不存在, 依然会读取Podfile文件内的框架信息
pod update //update outdated project dependencies and create new podfile.lock
不管Podfile.lock是否存在, 都会读取Podfile文件的的框架信息去下载,
下载好之后, 再根据下载好的框架信息, 生成Podfile.lock文件
网友评论