Podspec Syntax Reference v1.8.4
Root specification
s.name #庫名
s.version #版本號
s.summary #摘要
s.author
s.authors #庫的作者 單人或多人 s.author = { 'xiaoming' => 'xiaoming@qq.com.cn' }
s.license #版權許可 # s.license = { :type => 'MIT', :file => 'LICENSE' }
s.license = {
:type => 'Copyright',
:text => <<-LICENCE
Copyright 2013 Bestpay. All rights reserved.
LICENCE
}
s.homepage #pod主頁
s.source #庫源碼地址
:git => :tag, :branch, :commit, :submodules
s.source = { :git => 'https://gitlab.xxx.com.cn/mbp/sdk-ios-messagepush.git', :branch => "release/#{s.version}"}
'以上是必須設置的'
swift_versions #支持的swift版本
cocoappods_version #支持的 CocoaPods 版本號 s.cocoapods_version = '>= 0.36'
social_media_url #門戶網站
s.description #描述
s.screenshots #快照
s.documentation_url #文檔地址
prepare_command #預處理腳本 此命令在清理pod和創建pods項目之前執行。工作目錄是pod的根目錄。如果pod安裝了:path選項,則不會執行此命令。
static_framework #導出為靜態庫 'spec.static_framework = true'
deprecated #是否棄用 'spec.deprecated = true'
deprecated_in_favor_of #被棄用的庫 spec.deprecated_in_favor_of = 'NewMoreAwesomePod'
Platform
s.platform #支持的平臺及版本號
spec.platform = :osx, '10.8'
spec.platform = :ios
spec.platform = :osx
s.deployment_target #最低要求系統版本
spec.ios.deployment_target = '6.0'
spec.osx.deployment_target = '10.8'
Build settings
dependency #依賴屬性
spec.dependency 'AFNetworking', '~> 1.0'
spec.dependency 'RestKit/CoreData', '~> 0.20.0'
spec.ios.dependency 'MBProgressHUD', '~> 0.5'
info_plist #寫入info.plist文件
spec.info_plist = {
'CFBundleIdentifier' => 'com.myorg.MyLib',
'MY_VAR' => 'SOME_VALUE'
}
requires_arc #是否使用arc
Defaults:
spec.requires_arc = true
Examples:
spec.requires_arc = false
spec.requires_arc = 'Classes/Arc'
spec.requires_arc = ['Classes/*ARC.m', 'Classes/ARC.mm']
frameworks #依賴系統庫
spec.ios.framework = 'CFNetwork'
spec.frameworks = 'QuartzCore', 'CoreData'
weak_frameworks #弱依賴庫
spec.weak_framework = 'Twitter'
spec.weak_frameworks = 'Twitter', 'SafariServices'
libraries #依賴的系統靜態庫
spec.ios.library = 'xml2'
spec.libraries = 'xml2', 'z'
compiler_flags #傳遞給編譯器的參數
spec.compiler_flags = '-DOS_OBJECT_USE_OBJC=0', '-Wno-format'
pod_target_xcconfig #私有庫添加的flag
spec.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-lObjC' }
user_target_xcconfig #不推薦使用
spec.user_target_xcconfig = { 'MY_SUBSPEC' => 'YES' }
prefix_header_contents #不推薦 Any content to inject in the prefix header of the pod project.
spec.prefix_header_contents = '#import <UIKit/UIKit.h>'
spec.prefix_header_contents = '#import <UIKit/UIKit.h>', '#import <Foundation/Foundation.h>'
module_name #模塊
header_dir
header_mappings_dir
script_phases
File patterns
source_files #源代碼路徑
spec.source_files = 'Classes/**/*.{h,m}', 'More_Classes/**/*.{h,m}'
public_header_files #公開的頭文件 spec.public_header_files = 'Headers/Public/*.h' 如果不設置,默認將sources中的頭文件公開
private_header_files #不公開的頭文件
vendored_frameworks #引入的第三方framework
spec.ios.vendored_frameworks = 'Frameworks/MyFramework.framework'
spec.vendored_frameworks = 'MyFramework.framework', 'TheirFramework.framework'
vendored_libraries #引入的第三方.a
resource_bundles #動態庫所使用的資源文件存放位置,放在Resources文件夾中
spec.ios.resource_bundle = { 'MapBox' => 'MapView/Map/Resources/*.png' }
spec.resource_bundles = {
'MapBox' => ['MapView/Map/Resources/*.png'],
'MapBoxOtherResources' => ['MapView/Map/OtherResources/*.png']
}
resources #資源文件
spec.resource = 'Resources/HockeySDK.bundle'
spec.resources = ['Images/*.png', 'Sounds/*']
exclude_files #目標路徑下的文件不進行下載
spec.ios.exclude_files = 'Classes/osx'
spec.exclude_files = 'Classes/**/unused.{h,m}'
preserve_paths #下載后不應刪除的任何文件
spec.preserve_path = 'IMPORTANT.txt'
spec.preserve_paths = 'Frameworks/*.framework'
module_map #映射
spec.module_map = 'source/module.modulemap'
Subspecs
subspec #子模塊
Pod::Spec.new do |s|
s.name = 'Root'
s.subspec 'Level_1' do |sp|
sp.subspec 'Level_2' do |ssp|
end
end
end
requires_app_host #是否允許運行測試
test_spec.requires_app_host = true
app_host_name #app 主機
scheme
test_spec
app_spec
default_subspecs
Multi-Platform support
ios
spec.ios.source_files ='Classes/ios/**/*.{h,m}'
osx
macos
tvos
watchos
參考:Podspec Syntax Reference v1.8.4