软件测试之性能测试(ios)——使用Cocoapods创建自己的Cocoapods公共库

在做IOS测试的时候,经常会使用一些开源软件,而集成开源软件最方便的方式,就是使用cocoapods。如果要对开源软件二次开发,定制一些适合自己业务的东西,就需要clone开源软件,创建自己的Cocoapods公共库

1、clone开源代码到自己的仓库,然后下载到本地

我这里用的是sourcetree:
在这里插入图片描述

2、然后修改开源软件的spec描述文件 或者 创建描述文件

创建描述文件命令如下:

pod spec create NewLLDebugTool

修改后的spec描述文件如下:

Pod::Spec.new do |s|
  s.name                = "NewLLDebugTool"
  s.version             = "1.2.9"
  s.summary             = "NewLLDebugTool is a debugging tool for developers and testers that can help you analyze and manipulate data in non-xcode situations."
  s.homepage            = "https://github.com/didiaodanding/NewLLDebugTool"
  s.license             = "MIT"
  s.author              = { "haleli" => "1404012659@qq.com" }
  s.social_media_url    = "https://github.com/didiaodanding"
  s.platform            = :ios, "8.0"
  s.source              = { :git => "https://github.com/didiaodanding/NewLLDebugTool.git", :tag => s.version }
  s.requires_arc        = true
  s.public_header_files = "NewLLDebugTool/**/*.h"
  s.source_files     = "NewLLDebugTool/**/*.{h,m}"
  s.resources      = "NewLLDebugTool/**/*.{xib,storyboard,bundle}"
#  s.dependency            "FMDB"
  s.framework      = 'IOKit'

  s.subspec 'Network' do |ss|
    ss.source_files             = "NewLLDebugTool/Components/Network/**/*.{h,m}"
    ss.resources                = "NewLLDebugTool/Components/Network/**/*.{xib,storyboard,bundle}"
    ss.public_header_files      = "NewLLDebugTool/Components/Network/**/*.h"
    ss.dependency                 "NewLLDebugTool/StorageManager"
  end

  s.subspec 'Log' do |ss|
    ss.source_files             = "NewLLDebugTool/Components/Log/**/*.{h,m}"
    ss.resources                = "NewLLDebugTool/Components/Log/**/*.{xib,storyboard,bundle}"
    ss.public_header_files      = "NewLLDebugTool/Components/Log/**/*.h"
    ss.dependency                 "NewLLDebugTool/StorageManager"
  end

  s.subspec 'Crash' do |ss|
    ss.source_files             = "NewLLDebugTool/Components/Crash/**/*.{h,m}"
    ss.resources                = "NewLLDebugTool/Components/Crash/**/*.{xib,storyboard,bundle}"
    ss.public_header_files      = "NewLLDebugTool/Components/Crash/**/*.h"
    ss.dependency                 "NewLLDebugTool/StorageManager"
  end

  s.subspec 'AppInfo' do |ss|
    ss.source_files             = "NewLLDebugTool/Components/AppInfo/**/*.{h,m}"
#    ss.resources                = "LLDebugTool/Components/AppInfo/**/*.{xib,storyboard,bundle}"
    ss.public_header_files      = "NewLLDebugTool/Components/AppInfo/**/*.h"
    ss.dependency                 "NewLLDebugTool/General"
  end

  s.subspec 'Sandbox' do |ss|
    ss.source_files             = "NewLLDebugTool/Components/Sandbox/**/*.{h,m}"
    ss.resources                = "NewLLDebugTool/Components/Sandbox/**/*.{xib,storyboard,bundle}"
    ss.public_header_files      = "NewLLDebugTool/Components/Sandbox/**/*.h"
    ss.dependency                 "NewLLDebugTool/General"
  end

  s.subspec 'Screenshot' do |ss|
    ss.source_files             = "NewLLDebugTool/Components/Screenshot/**/*.{h,m}"
#    ss.resources                = "LLDebugTool/Components/Screenshot/**/*.{xib,storyboard,bundle}"
    ss.public_header_files      = "NewLLDebugTool/Components/Screenshot/**/*.h"
    ss.dependency                 "NewLLDebugTool/General"
  end

  s.subspec 'StorageManager' do |ss|
    ss.source_files             = "NewLLDebugTool/Components/StorageManager/**/*.{h,m}"
#    ss.resources               = "LLDebugTool/Components/StorageManager/**/*.{xib,storyboard,bundle}"
    ss.public_header_files      = "NewLLDebugTool/Components/StorageManager/**/*.h"
    ss.dependency                 "FMDB"
    ss.dependency                 "NewLLDebugTool/General"
  end

  s.subspec 'General' do |ss|
    ss.source_files             = "NewLLDebugTool/Config/*.{h,m}" , "NewLLDebugTool/Components/General/**/*.{h,m}"
    ss.resources                = "NewLLDebugTool/Components/General/**/*.{xib,storyboard,bundle}"
    ss.public_header_files      = "NewLLDebugTool/Config/*.h" , "NewLLDebugTool/Components/General/**/*.h"
  end

end

如果描述文件不知道怎么写,可以到官网查看描述文件

3、写好描述文件后,把项目提交到Github上面,并且打上对应 s.version的tag

在这里插入图片描述

4、注册cocoapods账号并且检查描述文件是否有错

如果是第一次发布自己的cocoapods,需要注册cocoapods账号,执行如下命令:

pod trunk register 1404012659@qq.com "haleli"

执行完命令后,会往你的邮箱发送验证链接,登录邮箱点击验证即可,如下图所示。

在这里插入图片描述
然后验证本地描述文件是否有错,执行下面的命令:

pod lib lint

如果校验文件通过,会输出如下结果:
在这里插入图片描述

5、执行发布命令,发布自己的Cocoapods公共库

pod trunk push NewLLDebugTool.podspec

发布成功后,会出现如下结果:
在这里插入图片描述

6、tips

1、如果podfile文件不想引用Cocoapods公共库里面的内容,而是想引用github里面最新的内容,Podfile可以如下编写

pod 'NewLLDebugTool' ,  :git => 'https://github.com/didiaodanding/NewLLDebugTool.git'

2、依赖的系统动态库,spec文件语法:

s.framework = 'IOKit'

3、pod spec lint编译时报error: include of non-modular header inside framework module

在命令后面加上–use-libraries

4、you may set use_modular_headers! globally in your Podfile, or specify :modular_headers => true for particular dependencies.

在命令后面加上 --use-modular-headers

完整的命令如下

pod lib lint --use-libraries --use-modular-headers --allow-warnings --verbose
pod trunk push --use-libraries --use-modular-headers --allow-warnings --verbose

5、如果工程编译报 duplicate symbol(重复符号) 的问题,在podfile文件里面加入use_frameworks!命令

project 'abcmouse'
target 'abcmouse-mobile' do
    use_frameworks!
    pod 'NewLLDebugTool' ,  :git => 'https://github.com/didiaodanding/NewLLDebugTool.git'
end

6、版本控制和冲突
CocoaPods 使用语义版本控制 - Semantic Versioning 命名约定来解决对版本的依赖。由于冲突解决系统建立在非重大变更的补丁版本之间,这使得解决依赖关系变得容易很多。例如,两个不同的 pods 依赖于 CocoaLumberjack 的两个版本,假设一个依赖于 2.3.1,另一个依赖于 2.3.3,此时冲突解决系统可以使用最新的版本 2.3.3,因为这个可以向后与 2.3.1 兼容。

但这并不总是有效。有许多第三方库并不使用这样的约定,这让解决方案变得非常复杂。

当然,总会有一些冲突需要手动解决。如果一个库依赖于 CocoaLumberjack 的 1.2.5,另外一个库则依赖于 2.3.1,那么只有最终用户通过明确指定使用某个版本来解决冲突。

参考文章

1、https://www.jianshu.com/p/264b4381237a
2、https://juejin.im/post/5ab0b0d9f265da2392362be0
3、https://www.jianshu.com/p/41611b14942b
4、https://blog.csdn.net/mingmingsuper/article/details/79558406
5、https://blog.csdn.net/jks456/article/details/78873731
6、https://juejin.im/entry/57b3bafd6be3ff006a06baa4
7、https://www.ctolib.com/tianNanYiHao-SOCR.html
8、https://wiki.jikexueyuan.com/project/objc/Build-tool/6-4.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值