CocoaPods学习02-PodSpec
CocoaPods学习03-pod install vs pod update
CocoaPods学习04-制作自己的pod库
命令语法
-
install!设置安装方法和参数 方法现在仅支持'cocoapods',它的参数文档未做说明,具体待查
install! 'cocoapods' -
pod指出依赖关系-
pod 'AFNetworking', ~>3.0.0版本号依赖不做过多解释,* 版本号-
pod 'ABC'始终使用最新版本 -
pod 'ABC', '0.9'只使用0.9这个版本 - 版本号支持
>,>=,<,<=符号
<= 0.9任何小于0.9版本 -
~> 1.2.3大于等于1.2.3但是小于'1.3',倒数第一个数字可变但是要大于等于它,一般开发使用这种方式,这样可以避免pod库进行了大改动,我们需要适配代码
-
-
build configurations编译配置设置
pod 'ZJJDebugger', :configuration => 'Debug'只在debug环境下配置 -
subspecs子模块依赖
pod 'QueryKit', :subspecs => ['Attribute', 'QuerySet'],只引入该库下的后两个模块 -
指定本地文件库依赖
pod 'ABC', :path => '~/Documents/ABC' -
指定引入的分支,tag,提交号
- 默认mater
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git' - 引入其他分支
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'dev' - 引入某个tag处
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '3.1.1' - 引入某次提交处 `pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :commit => 'ssfsdf23123'
- 默认mater
-
如果某个lib在它的仓库外面没有
podspec,也可以从其他位置引入该podspec
pod 'JSONKit', :podspec => 'https://example.com/JSONKit.podspec'
-
-
target需要指向Xcode target
abstract_target抽象基类target,不能指向具体的Xcode target
inherit!继承target# Note: 定义一个抽象基类target abstract_target 'Shows' do pod 'ShowsKit' # ShowsiOS 继承'ShowsKit'和自己的'ShowWebAuth' target 'ShowsiOS' do pod 'ShowWebAuth' end # ShowsTw 继承'ShowsKit'和自己的'ShowTVAuth' target 'ShowsTV' do pod 'ShowTVAuth' end # ShowsTests 继承’search_paths‘跟默认一样全部继承 ’none‘是不继承 target 'ShowsTests' do inherit! :search_paths pod 'Specta' pod 'Expecta' end end -
inhibit_all_warnings!屏蔽所有警告
inhibit_warnings => true指定屏蔽或者不屏蔽具体库的警告
pod 'SSZipArchive', :inhibit_warnings => false -
source默认是官方source,但是当你使用自己的source源后,也得把官方的source显示添加进去source 'https://github.com/artsy/Specs.git' source 'https://github.com/CocoaPods/Specs.git' -
plugin安装插件
plugin 'slather'
pre_install下载完安装前指定操作
post_install安装完写入磁盘前指定操作post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['GCC_ENABLE_OBJC_GC'] = 'supported' end end end
示例
platform :ios, '9.0'
inhibit_all_warnings!
target 'MyApp' do
pod 'ObjectiveSugar', '~> 0.5'
target "MyAppTests" do
inherit! :search_paths
pod 'OCMock', '~> 2.0.1'
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['GCC_ENABLE_OBJC_GC'] = 'supported'
end
end
end
参考地址
cocoapods guides







网友评论