一、.podspec的一些说明
一个简单示例:
Pod::Spec.new do |s|
s.name = 'RecordModule'
s.version = '0.1.0'
s.summary = '录音组件'
s.description = <<-DESC
录音组件
DESC
s.homepage = 'https://github.com/AncientMing/RecordModule'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'AncientMing' => 'chenyun@vkel.cn' }
s.source = { :svn => 'http://app-cheny@192.168.2.110:8088/svn/06-project/A-APP/0-code/%E4%BA%91%E5%9B%BE%E6%BC%AB%E6%AD%A5_Modularization_2018/RecordModule_yuntu', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.public_header_files = 'RecordModule/Classes/**/VKMessageHeader.h'
s.source_files = 'RecordModule/Classes/*'
s.resource_bundles = {
'RecordModule' => ['RecordModule/Assets/*.png']
}
s.dependency 'CYBasicsModule'
s.subspec 'FGRecordManage' do |ss|
ss.source_files = 'RecordModule/Classes/**/FGRecordManage/**/*'
end
end
在使用pod的过程中,需要用到.podspec文件,也就是配置文件
做个说明记录。
1、最外层,格式化样板就好
Pod::Spec.new do |s|
end
2、name
组件名称
s.name = 'RecordModule'
3、version
组件版本
s.version = '0.1.0'
4、summary
组件概要说明
s.summary = '录音组件'
5、description
组件详细说明
s.description = <<-DESC
录音组件
DESC
6、homepage
首页,有的话把网址放出来。
s.homepage = 'https://github.com/AncientMing/RecordModule'
7、license
协议,MIT,随便拷贝,随便用
s.license = { :type => 'MIT', :file => 'LICENSE' }
示例2,指定许可文件的内容
spec.license = { :type => 'MIT', :text => <<-LICENSE
Copyright 2012
Permission is granted to...
LICENSE
}
8、author
作者信息
s.author = { 'AncientMing' => 'chenyun@vkel.cn' }
若果有多个作者,可以这样写
spec.authors = 'Darth Vader', 'Wookiee'
示例2
spec.authors = { 'Darth Vader' => 'darthvader@darkside.com',
'Wookiee' => 'wookiee@aggrrttaaggrrt.com' }
9、source
资源所在地,
示例1,svn地址
s.source = { :svn => 'http://app-cheny@192.168.2.110:8088/svn/06-project/A-APP/0-code/%E4%BA%91%E5%9B%BE%E6%BC%AB%E6%AD%A5_Modularization_2018/RecordModule_yuntu', :tag => s.version.to_s }
示例2,项目git地址,tag值与spec.verison版本一致
spec.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git',
:tag => spec.version.to_s }
示例3,项目git地址,tag值以v开头,支持子模块(子模块是git的子模块)
spec.source = { :git => 'https://github.com/typhoon-framework/Typhoon.git',
:tag => "v#{spec.version}", :submodules => true }
示例4,项目压缩包地址
spec.source = { :http => 'http://dev.wechatapp.com/download/sdk/WeChat_SDK_iOS_en.zip' }
示例5,指定压缩包地址,并校验hash值,支持sha1 和 sha256
spec.source = { :http => 'http://dev.wechatapp.com/download/sdk/WeChat_SDK_iOS_en.zip',
:sha1 => '7e21857fe11a511f472cfd7cfa2d979bd7ab7d96' }
10、deployment_target
支持的版本
s.ios.deployment_target = '8.0'
11、public_header_files
公开的头文件
s.public_header_files = 'RecordModule/Classes/**/VKMessageHeader.h'
12、source_files
资源文件
s.source_files = 'RecordModule/Classes/*'
13、resource_bundles
资源包,一般图片之类,这种方式资源文件会被以bundle的形式加入到项目中去,官方建议使用的方式,主要是防止与用户的命名方式冲突
s.resource_bundles = {
'RecordModule' => ['RecordModule/Assets/*.png']
}
示例2
spec.ios.resource_bundle = { 'MapBox' => 'MapView/Map/Resources/*.png' }
多个路径
spec.resource_bundles = {
'MapBox' => ['MapView/Map/Resources/*.png'],
'OtherResources' => ['MapView/Map/OtherResources/*.png']
}
资源文件另一种方式,这种比较常见
spec.resource = 'Resources/HockeySDK.bundle'
spec.resources = ['Images/*.png', 'Sounds/*']
14、dependency
依赖
s.dependency 'CYBasicsModule'
指定版本
spec.dependency 'AFNetworking', '~> 1.0'
15、subspec
子文件夹
s.subspec 'FMDB' do |ss|
ss.source_files = 'RecordModule/Classes/**/FMDB/**/*'
end
16、vendored_libraries
依赖的第三方.a库
ss.vendored_libraries = 'RecordModule/Classes/**/*.{a}'
17、vendored_frameworks
依赖的第三方framework库
ss.vendored_frameworks = 'MessageModule/Classes/**/*.{framework}'
18、frameworks
依赖的系统framework库
s.frameworks = 'CoreLocation','QuartzCore'
19、libraries
依赖的系统非framework库
s.libraries = 'sqlite3.0'
20、screenshots
截屏图
s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
单个截图
spec.screenshot = 'http://dl.dropbox.com/u/378729/MBProgressHUD/1.png'
21、social_media_url
社交URL
s.social_media_url = 'https://twitter.com/AFNetworking'
22、requires_arc
是否ARC文件,默认true,如果不是,会自动添加-fno-objc-arc compiler flag
是 ARC文件如下
ss.requires_arc = true
不是 ARC文件如下
ss.requires_arc = false
部分是ARC
spec.requires_arc = false
spec.requires_arc = 'Classes/Arc' //该文件夹下是ARC,其它非ARC
spec.requires_arc = ['Classes/*ARC.m', 'Classes/ARC.mm']
23、pch_AF
pch文件
pch_AF = <<-EOS
#ifndef TARGET_OS_IOS
#define TARGET_OS_IOS TARGET_OS_IPHONE
#endif
#ifndef TARGET_OS_WATCH
#define TARGET_OS_WATCH 0
#endif
#ifndef TARGET_OS_TV
#define TARGET_OS_TV 0
#endif
EOS
24、prefix_header_contents
类似于pch,文件,多个用逗号隔开
示例1
s.prefix_header_contents = pch_AF
示例2
spec.prefix_header_contents = '#import <UIKit/UIKit.h>', '#import <Foundation/Foundation.h>'
示例3
s.prefix_header_contents = <<-EOS
#ifdef __OBJC__
#import "SGExtension.h" //SGExtension包含了所有头文件
#endif
EOS
end
示例4
spec.prefix_header_file = 'iphone/include/prefix.pch'
25、private_header_files
私有头文件
spec.private_header_files = 'Headers/Private/*.h'
26、documentation_url
文档说明
spec.documentation_url = 'http://www.example.com/docs.html'
27、prepare_command
在pod文件下载完毕之后,执行的命令,原文如下
A bash script that will be executed after the Pod is downloaded. This command can be used to create, delete and modify any file downloaded and will be ran before any paths for other file attributes of the specification are collected.
This command is executed before the Pod is cleaned and before the Pods project is created. The working directory is the root of the Pod.
If the pod is installed with the :path option this command will not be executed.
单个命令
spec.prepare_command = 'ruby build_files.rb'
多条命令
spec.prepare_command = <<-CMD
sed -i 's/MyNameSpacedHeader/Header/g' ./**/*.h
sed -i 's/MyNameOtherSpacedHeader/OtherHeader/g' ./**/*.h
CMD
28、deprecated
是否过期
spec.deprecated = true
29、平台
如果不写默认支持所有平台
各个平台
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.9'
s.watchos.deployment_target = '2.0'
s.tvos.deployment_target = '9.0'
支持的平台,仅支持
spec.platform = :ios //仅支持ios
30、weak_frameworks
如果在高版本的OS中调用新增的功能,并且在低版本的OS中依然能够运行,那么就要用到weak_frameworks.如果引用的某些类或者接口在低版本中并不支持,对于不支持的接口,可以在运行的时候判断,这样程序不会出错,如果不weak引用,程序在低版本下启动的时候就会崩溃掉
spec.weak_framework = 'MessageUI'
31、compiler_flags
spec.compiler_flags = '-DOS_OBJECT_USE_OBJC=0', '-Wno-format'
二、文件匹配
*
匹配所有文件
c*
匹配以名字C开头的文件
*c
匹配以名字c结尾的文件
*c*
匹配所有名字包含c的文件
**
文件夹以及递归子文件夹
?
任意一个字符(注意是一个字符)
[set]
匹配多个字符,支持取反
{p,q}
匹配名字包括p 或者 q的文件
例子:
"JSONKit.?" #=> ["JSONKit.h", "JSONKit.m"] //JSONKit.字符
"*.[a-z][a-z]" #=> ["CHANGELOG.md", "README.md"]//.两个a-z的字母
"*.[^m]*" #=> ["JSONKit.h"] //.不是m的字符
"*.{h,m}" #=> ["JSONKit.h", "JSONKit.m"] //包含.h或者.m
"*" #=> ["CHANGELOG.md", "JSONKit.h", "JSONKit.m", "README.md"]//所有文件
网友评论