组件化---创建私有Spec Repo管理项目公共组件库(下)

1、更新组件版本

  • 1、在我们之前的公共组件库添加一些组件,然后打上tag提交到git仓库。
#提交到远程仓库
sy@MacBook-Pro ~/D/HSPodLib> git add .
sy@MacBook-Pro ~/D/HSPodLib>git commit -m '添加公共组件库'
sy@MacBook-Pro ~/D/HSPodLib> git push origin master
#设置tag
sy@MacBook-Pro ~/D/HSPodLib>git tag -m "添加公共组件库" 0.2.0
sy@MacBook-Pro ~/D/HSPodLib> git push --tags
  • 2、修改HSPodLib中的.podspec文件的s.version对应的值
#
# Be sure to run `pod lib lint HSPodLib.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = 'HSPodLib'
  s.version          = '0.2.0'
  s.summary          = 'HSPodLib second test need'

# This description is used to generate tags and improve search results.
#   * Think: What does it do? Why did you write it? What is the focus?
#   * Try to keep it short, snappy and to the point.
#   * Write the description between the DESC delimiters below.
#   * Finally, don't worry about the indent, CocoaPods strips it!

  s.description      = <<-DESC
TODO: must description HSPodLib why? YES!  HSPodLib need test
                       DESC

  s.homepage         = 'https://github.com/sunWaterMood/HSPodLib'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'sunWaterMood' => '1095143828@qq.com' }
  s.source           = { :git => 'https://github.com/sunWaterMood/HSPodLib.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.ios.deployment_target = '9.0'

  s.source_files = 'HSPodLib/Classes/**/*'
  
  # s.resource_bundles = {
  #   'HSPodLib' => ['HSPodLib/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'
end

  • 3、执行 pod lib lint
sy@MacBook-Pro ~/D/HSPodLib> pod lib lint
  • 4、把.podsepc文件同步到本地仓库
sy@MacBook-Pro ~/D/HSPodLib>pod repo push HSSpec HSPodLib.podspec

执行结果

Validating spec
 -> HSPodLib (0.5.0)
    - NOTE  | xcodebuild:  note: Using new build system
    - NOTE  | xcodebuild:  note: Building targets in parallel
    - NOTE  | xcodebuild:  note: Using codesigning identity override: -
    - NOTE  | [iOS] xcodebuild:  note: Planning build
    - NOTE  | [iOS] xcodebuild:  note: Constructing build description
    - NOTE  | [iOS] xcodebuild:  warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')

Updating the `HSSpec' repo


Adding the spec to the `HSSpec' repo

 - [Update] HSPodLib (0.5.0)

Pushing the `HSSpec' repo

2、创建subspec

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

  • 1、首先我们需要源代码的存放文件夹
    在这里插入图片描述
  • 2、然后我们编辑.podspec文件
#
# Be sure to run `pod lib lint HSPodLib.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = 'HSPodLib'
  s.version          = '0.2.0'
  s.summary          = 'HSPodLib second test need'

# This description is used to generate tags and improve search results.
#   * Think: What does it do? Why did you write it? What is the focus?
#   * Try to keep it short, snappy and to the point.
#   * Write the description between the DESC delimiters below.
#   * Finally, don't worry about the indent, CocoaPods strips it!

  s.description      = <<-DESC
TODO: must description HSPodLib why? YES!  HSPodLib need test
                       DESC

  s.homepage         = 'https://github.com/sunWaterMood/HSPodLib'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'sunWaterMood' => '1095143828@qq.com' }
  s.source           = { :git => 'https://github.com/sunWaterMood/HSPodLib.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.ios.deployment_target = '9.0'
   # subspec的定义
  s.subspec 'Category' do |category|
    # 创建subspec的时候文件夹必须要有文件,不然就会报错 验证不通过
    category.source_files = 'HSPodLib/Classes/Category/**/*'
    #category.public_header_files = 'HSPodLib/Classes/HSPodLib/**/*.h'
  end

  #s.source_files = 'HSPodLib/Classes/**/*'
  
  # s.resource_bundles = {
  #   'HSPodLib' => ['HSPodLib/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'
end

  • 3、重复执行pod lib lint 、pod repo push HSSpec HSPodLib.podspec

至此完成。如有问题,请联系我。谢谢。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值