podspec文件介绍

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

 

 
posted @ 2016-12-08 22:24  滴水微澜  阅读(5064)  评论(0编辑  收藏  举报