CocoaPods學習02-PodSpec
CocoaPods學習03-pod install vs pod update
CocoaPods學習04-制作自己的pod庫
命令語法
install!
設置安裝方法和參數(shù) 方法現(xiàn)在僅支持'cocoapods'
甥雕,它的參數(shù)文檔未做說明社露,具體待查
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'附鸽,倒數(shù)第一個數(shù)字可變但是要大于等于它瞒瘸,一般開發(fā)使用這種方式,這樣可以避免pod庫進行了大改動情臭,我們需要適配代碼
-
build configurations
編譯配置設置
pod 'ZJJDebugger', :configuration => 'Debug'
只在debug環(huán)境下配置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