podspec文件是cocopods引入的第三方代碼庫的配置索引文件
它的創建命令是:$pod spec create TestFile
podspec文件的常用配置字段介紹
Pod::Spec.new do |spec| spec.name = "BottomComponentLib" spec.version = "1.0.0" spec.summary = "底層組件庫" spec.description = <<-DESC 目前支持的功能有: DESC spec.homepage = "www.baidu.com" //框架遵守的開源協議 spec.license = 'MIT' spec.author = { "zf" => "1174977961@qq.com" } //本地框架文件索引,相對podspec文件的目錄 spec.source = { :path => 'BottomComponentLib',} //遠程框架文件索引,可以根據版本號,tag號 #spec.source = { :git => "https://github.com/zhfei/BottomComponentLib.git", :commit => "a1a94661"} #spec.source = { :git => "https://github.com/zhfei/BottomComponentLib.git", :tag =>spec.version} //框架支持的最低平台版本 spec.platform = :ios, '8.0' //同上面功能一樣 spec.ios.deployment_target = '8.0' spec.requires_arc = true //框架公開的頭文件,能夠使用<>方法 spec.public_header_files = 'SRC/**/*.{h}' //功能同上 spec.ios.public_header_files = 'SRC/**/*.{h}' //框架被引用時,會下載此目錄下的文件 spec.source_files = 'SRC/**/*.{h,m,plist}' //框架被引用時,會下載此目錄下的資源文件 spec.resource_bundles = { 'BottomComponentLib' => [ 'SRC/**/*.{storyboard,xcassets,xib,plist}' ] } //功能同上 spec.resources = { 'yoowei' => ['yoowei/resource/**/*.{storyboard,xcassets,xib,png'] } //依賴frameworks spec.frameworks ='Foundation', 'CoreGraphics', 'UIKit' //依賴libraries tdd3.libraries = "xml2" //依賴第三方庫 spec.dependency 'AFNetworking', '~> 2.3' spec.dependency 'MBProgressHUD' spec.dependency 'YYModel' //子目錄 spec.subspec "Object-C" do |oc| oc.source_files = 'SRC/Object-C/*.{h,m}' end spec.subspec "Swift" do |sf| sf.source_files = 'SRC/Swift/*.{strings}' end spec.subspec "Resouce" do |rs| rs.source_files = 'SRC/Resouce/*.{storyboard,xcassets,xib,plist,strings}' end spec.subspec "TestDir2" do |td2| //下載HycProject文件夾下AppInfo的.h和.m文件 td2.source_files = 'HycProject/AppInfo.{h,m}' //允許使用import<AppInfo.h> td2.public_header_files = 'HycProject/AppInfo.h' //依賴的frameworks td2.ios.frameworks = 'MobileCoreServices', 'CoreGraphics' td2.subspec "TestDir3" do |tdd3| //最低要求的系統版本7.0 tdd3.ios.deployment_target = '8.0' //所有文件默認都是private的,只允許使用import"AppInfo.h"訪問 tdd3.ios.private_header_files = 'AppInfo/Info/**/*.h' // 下載路徑下的.h/.m/.c文件 tdd3.ios.source_files = 'AppInfo/Info/**/*.{h,m,c}' //引用xml2庫,但系統會找不到這個庫的頭文件,需與下方sss.xcconfig配合使用(這里省略lib) tdd3.libraries = "xml2" //在pod target項的Header Search Path中配置:${SDK_DIR}/usr/include/libxml2 tdd3.xcconfig = { 'HEADER_SEARCH_PATHS' => '${SDK_DIR}/usr/include/libxml2' } //json目錄下的文件不做下載 tdd3.ios.exclude_files = 'AppInfo/Info/json' end end end