CocoaPods

CocoaPods关于podsepc文件设置详解

2021-09-12  本文已影响0人  新生代农民工No1

这篇文章中,将会介绍podsepc文件的详细设置,参考文档

设置名称:

名称将会帮助别人找到你的库 pod search XXXX

spec.name = "XXXX"
设置版本号:
spec.version = "0.0.1"
设置概要:

较为简洁的描述

spec.summary = ""
设置描述:

描述信息将用于生成标签和改进搜索结果

spec.description = ""
设置主页:
spec.homepage = "https://github.com/xxxx"
设置许可:

官方许可,目前主流使用的 'MIT', 'BSD',详情可以查看文档

spec.license = { :type => "MIT", :file => "LICENSE" }
设置作者信息:

指定这个库的作者的名称以及邮箱地址

spec.author  = { "xxxx" => "xxxxxx@google.com" }
spec.authors  = { "xxxx" => "xxxxxx@google.com", "xxxy" => "xxxxxy@google.com" }
设置平台信息:
spec.platform = :ios, "9.0"
// 使用多平台
spec.ios.deployment_target = "5.0"
spec.osx.deployment_target = "10.7"
spec.watchos.deployment_target = "2.0"
spec.tvos.deployment_target = "9.0"
设置源地址:
spec.source = { :git => "https://github.com/xxxx/project.git", :tag => "#{spec.version}" }
设置源代码:
// 源代码目录
spec.source_files  = "Classes", "Classes/**/*.{h,m}"
// 头文件
spec.public_header_files = "Classes/**/*.h"
设置资源文件:
spec.resource = "icon.png"   
spec.resource_bundles = "Resources/*.png"
项目链接:

将库与frameworkslibraries链接。库不包括其名称的lib前缀

spec.framework  = "SomeFramework"
spec.frameworks = "SomeFramework", "AnotherFramework"

spec.library   = "iconv"
spec.libraries = "iconv", "xml2"
项目设置:
// 设置ARC
spec.requires_arc = true
// 依赖pod库
spec.dependency "JSONKit", "~> 1.4"
// 配置信息,根据需求填写
spec.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
// 添加到该Pod target下的xcconfig文件
spec.pod_target_xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
// 添加到 用户 target下的xcconfig文件
spec.user_target_xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
子模块设置:

如果需要设置子模块,那么依赖库,pod,资源文件设置都是继承父模块的,所以可以重写这些属性:

spec.subspec 'xxxx' do |subp|
  subp.source_files = 'Classes/xxxx/'
  subp.public_header_files = 'Classes/xxxx/*.h'
  subp.dependency = 'AFNetworking'
  subp.frameworks = 'MapKit', 'CoreGraphics'
  // 依赖其他子模块
  subp.dependency = 'Classes/XXXX'
end

模块化设计可以参考文档

上一篇下一篇

猜你喜欢

热点阅读