一. Pod install!
- 定義了CocoaPods安裝podfile時(shí)的方式和選項(xiàng)
第一個(gè)參數(shù)指定了安裝的方式,下面的參數(shù)制定了安裝的選項(xiàng)
但是目前的CocoaPods只支持cocoapods
,所以你的第一個(gè)參數(shù)只能填cocoapods
,更多的參數(shù)會(huì)在未來的版本才支持??
舉個(gè)??
install! 'cocoapods',
??? :deterministic_uuids => false,
??? :integrate_targets => false
Supported Keys:
- :clean
默認(rèn)true
安裝的時(shí)候是否要清除pods里面無效的資源 - :deduplicate_targets
默認(rèn)true
是否支持多targets
target 'MyTargetA' do
pod 'MyPod/SubA'
endtarget 'MyTargetB' do
pod 'MyPod'
end
- :deterministic_uuids
默認(rèn)true
創(chuàng)建Pods project 是否生成一個(gè)確定的UUID - :integrate_targets 默認(rèn)true
是否把pods集成到用戶的工程下 如果這是為false缕允,Pods將被下載并安裝到
Pods/ `文件夾下蕾各,但是它們不會(huì)集成到你的工程中 - :lock_pod_sources
默認(rèn)true
是否鎖住pods的源文件。如果鎖定的話煞檩,當(dāng)你在pods的源文件中修改內(nèi)容時(shí)會(huì)彈窗警告腕扶。
在安裝過程中鎖定 pod 會(huì)降低性能糟描。 如果這對(duì)您的項(xiàng)目的 pod install 的持續(xù)時(shí)間有顯著影響荠藤,您可以嘗試將其設(shè)置為 false - :warn_for_multiple_pod_sources
默認(rèn)true
當(dāng)多個(gè)源包含具有相同名稱和版本的 Pod 時(shí)是否發(fā)出警告 - :warn_for_unused_master_specs_repo
默認(rèn)true
如果項(xiàng)目沒有明確指定基于 git 的主規(guī)范存儲(chǔ)庫(kù)伙单,則會(huì)發(fā)出警告 - :share_schemes_for_development_pods
默認(rèn)false
Whether to share Xcode schemes for development pods.
Schemes for development pods are created automatically but are not shared by default. - :disable_input_output_paths
默認(rèn)false
是否禁用 CocoaPods 腳本階段的輸入和輸出路徑(Copy Frameworks & Copy Resources) - :preserve_pod_file_structure
默認(rèn)false
是否保留所有 Pod 的文件結(jié)構(gòu),包括外部來源的 Pod哈肖。
By default, the file structure of Pod sources is preserved only for development pods.
默認(rèn)的吻育,只有在development pods模式下才會(huì)維護(hù)pod的源文件的結(jié)構(gòu)。
如果打開該選項(xiàng)淤井,會(huì)維護(hù)所有的包括第三方的pod的文件結(jié)構(gòu) - :generate_multiple_pod_projects
默認(rèn)false
是否為每個(gè) pod 目標(biāo)生成一個(gè)項(xiàng)目布疼。 與創(chuàng)建 1 個(gè) Pods.xcodeproj 不同,此選項(xiàng)將為每個(gè)嵌套在 Pods.xcodeproj 下的 Pod 目標(biāo)生成一個(gè)項(xiàng)目币狠。 - :incremental_installation
默認(rèn)false
是否只安裝 上次安裝后更改的pod庫(kù) - :skip_pods_project_generation
默認(rèn)false
是否跳過生成 Pods.xcodeproj 而只執(zhí)行依賴解析和下載游两。
二.ensure_bundler!
不解釋
三.Pod
- Build configurations
默認(rèn)dependencies會(huì)被安裝在target的所有設(shè)置項(xiàng)里面,但你也可以單獨(dú)設(shè)置這些選項(xiàng),如下所示
pod 'PonyDebugger', :configurations => ['Debug', 'Beta']
pod 'PonyDebugger', :configuration => 'Debug'
- Modular Headers
你想為每個(gè)pod使用模塊化的頭漩绵,可以使用pod 'SSZipArchive', :modular_headers => true
如果你使用了use_modular_headers!
,就代表每個(gè)pod都使用了模塊化的頭贱案,可以使用pod 'SSZipArchive', :modular_headers => false
排除某個(gè)pod - Subspecs
spec 美[spek] 投機(jī);說明書止吐;細(xì)則
pod 'QueryKit/Attribute'
pod 'QueryKit', :subspecs => ['Attribute', 'QuerySet']
- Test Specs
pod 'AFNetworking', :testspecs => ['UnitTests', 'SomeOtherTests']
- From a podspec in the root of a library repository.
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git'
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :branch => 'dev'
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :tag => '0.7.0'
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :commit => '082f8319af'
四. script_phase
可以執(zhí)行腳本
script_phase :name => 'HelloWorldScript', :script => 'echo "Hello World"'
script_phase :name => 'HelloWorldScript', :script => 'puts "Hello World"', :shell_path => '/usr/bin/ruby'
五.Target configuration
- platform
platform :ios, '4.0'
The name of platform, can be either :osx for OS X, :ios for iOS, :tvos for tvOS, or :watchos for watchOS.
- use_modular_headers!
對(duì)所有 CocoaPods 靜態(tài)庫(kù)使用模塊化頭文件宝踪。 - use_frameworks!
為 Pod 使用框架而不是靜態(tài)庫(kù)。使用框架時(shí)碍扔,您還可以指定要使用的 :linkage 樣式瘩燥,即 :static 或 :dynamic。
target 'MyApp' do
use_frameworks! :linkage => :dynamic
pod 'AFNetworking', '~> 1.0'
endtarget 'ZipApp' do
use_frameworks! :linkage => :static
pod 'SSZipArchive'
end
- supports_swift_versions
Specifies the Swift version requirements this target definition supports.
指定此目標(biāo)定義支持的 Swift 版本要求不同。
target 'MyApp' do
supports_swift_versions '>= 3.0', '< 4.0'
pod 'AFNetworking', '~> 1.0'
end
六. Hooks
- plugin
plugin 'cocoapods-keys', :keyring => 'Eidolon'
plugin 'slather'
- pre_install
適用時(shí)間:pods的代碼被下載成功但還沒有進(jìn)行安裝
pre_install do |installer|
Do something fancy!
end
- pre_integrate
項(xiàng)目被寫到磁盤之前
pre_integrate do |installer|
perform some changes on dependencies
end
- post_install
適用時(shí)間:生成了Xcode project但是還沒有寫入到磁盤
它接收 [Pod::Installer] 作為其唯一參數(shù)厉膀。
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
- post_integrate
適用時(shí)間:project已經(jīng)被寫入到了磁盤
post_integrate do |installer|
some change after project write to disk
end