podspec檔案介紹

滴水微瀾發表於2016-12-08

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

 

 

相關文章