CocoaPod 私有库Spec编辑注意事项

CocoaPod 私有库Spec依赖.a写法

PodSpec详细描述如下,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

Pod::Spec.new do |s|

# 库名称
s.name = 'AudioRecorder'

# 库的版本
s.version = '0.1.0'

# 库摘要
s.summary = 'AudioRecorder提供iOS录音和录音播放功能'

# 库描述
s.description = <<-DESC
AudioRecorder提供iOS录音和录音播放功能
DESC
# 远程仓库地址
s.homepage = 'https://github.com/xxx'

# 截图
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'

# MIT许可证,软件授权条款
s.license = { :type => 'MIT', :file => 'LICENSE' }

# 作者信息
s.author = { 'MorganWang' => 'xxx@163.com' }

# 支持的系统及支持的最低系统版本
# s.platform = :ios
# s.platform = :ios, "8.0"

# 支持多个平台使用时
s.ios.deployment_target = "10.0"
# s.osx.deployment_target = "10.7"
# s.watchos.deployment_target = "2.0"
# s.tvos.deployment_target = "9.0"

# 下载地址
s.source = { :git => 'xxx.git', :tag => s.version.to_s }

# 库文件在仓库中的相对路径
# 等号后面的第一个参数表示的是要添加 CocoaPods 依赖的库在项目中的相对路径
# 等号后面的第二个参数,用来指示文件夹下的哪些文件需要添加 CocoaPods 依赖
# “**”通配符表示文件夹下的所有文件,“*.{h,m}”代表所有的.h, .m文件
s.source_files = 'AudioRecorder/Classes/**/*'

# 设置不需要添加到 CocoaPods 的文件
# s.exclude_files = "xxx/Exclude"

# https://blog.csdn.net/w_shuiping/article/details/80606277
# CocoaPods中依赖的第三方.a或者.framework库
s.vendored_libraries = 'AudioRecorder/Classes/lame/*.a'

# s.resource_bundles = {
# 'AudioRecorder' => ['AudioRecorder/Assets/*.png']
# }

# s.public_header_files = 'Pod/Classes/**/*.h'

# 库中用到的框架或系统库
s.frameworks = 'UIKit', 'Foundation', 'AVFoundation'

# 库中依赖的其它CocoaPods的第三方库,依赖多个写多个s.dependency
s.dependency 'Masonry', '~> 1.1.0'
end



库校验

1
2
3

pod lib lint --allow-warnings

使用

使用tag或者使用分支,通常使用tag,因为tag代表功能的完整性。如果使用分支,随后在分支上继续开发,然后再次update依赖时,可能会出现新开发的内容未验证就被更新了或者不兼容的情况

1
2
3
4

pod 'xxx',:git=>'xxx.git',:tag=>'0.7.0'
pod 'yyy',:git =>'yyy.git',:branch=> 'develop'