程序员程序员首页投稿首页投稿(暂停使用,暂停投稿)

使用CocoaPods创建私有Spec Repo管理项目公共组件

2017-08-03  本文已影响136人  当红辣椒炒肉
CocoaPods

接上一篇

更新组件版本

# 添加代码到远程
git add .
git commit -m "0.2.0版本代码" 
git push origin master

# 设置版本tag
git tag -m  "0.2.0" 0.2.0
git push --tags
# 只需要修改版本号就可以
s.version          = '0.2.0'
pod 'HJPodTestLib', '~> 0.2.0'
pod update

创建subspec

一般我们的公共组件有很多类型的库,例如网络库,JSON库,工具库等,这样我们对库的管理就可以采取subspec的模式管理。

功能目录
Pod::Spec.new do |s|
  s.name             = 'HJPodTestLib'
  s.version          = '1.0.1'
  s.summary          = 'HJPodTestLib.'

  s.description      = <<-DESC
 description of the pod here.
                       DESC

  s.homepage         = 'https://github.com/OldGhost366/HJPodTestLib'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'OldGhost366' => 'oldghost007@163.com' }
  s.source           = { :git => 'https://github.com/OldGhost366/HJPodTestLib.git', :tag => s.version.to_s }

  s.ios.deployment_target = '8.0'

  # subspec的定义
  s.subspec 'NetworkEngine' do |networkEngine|
    # 创建subspec的时候文件夹必须要有文件,不然就会报错 验证不通过
    networkEngine.source_files = 'HJPodTestLib/Classes/NetworkEngine/**/*'
    networkEngine.public_header_files = 'HJPodTestLib/Classes/NetworkEngine/**/*.h' 
  end
  s.subspec 'CommonUtils' do |utils|
    utils.source_files = 'HJPodTestLib/Classes/CommonUtils/**/*'
    utils.public_header_files = 'HJPodTestLib/Classes/CommonUtils/**/*.h'
  end
end

在验证podspec文件的时候我遇到一个问题,按照上面的意思是没有找到文件,原来是我只新建了两个文件夹,但是没有在里面创建文件,我在里面创建两个文件就可以了。但是我在上一篇文章制作的时候没有遇到这个问题,我猜测可能是subspec才会去检测。

jdeMacBook-Pro:HJPodTestLib j$ pod lib lint

 -> HJPodTestLib (1.0.1)
    - ERROR | [iOS] [HJPodTestLib/CommonUtils] file patterns: The `source_files` pattern did not match any file.
    - ERROR | [iOS] [HJPodTestLib/CommonUtils] file patterns: The `public_header_files` pattern did not match any file.
pod 'HJPodTestLib/NetworkEngine', '~> 1.0.1'
上一篇 下一篇

猜你喜欢

热点阅读