iOS创建私有库经验总结

当前pod版本是1.9.1,具体查看

pod --version

1.创建带有demo项目的工程文件

pod lib create 代码库名字

2.编辑配置文件

#
# Be sure to run `pod lib lint BLEMeshDevice.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             = 'BLEMeshDevice'
  s.version          = '0.0.1'
  s.summary          = '天津九安医疗智能照明蓝牙mesh插件'

# 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
  天津九安医疗智能照明蓝牙mesh插件,版权归九安医疗所有
                       DESC

  s.homepage         = 'https://gitee.com/xxx/xxxx'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = {'叶情宇'=>'[email protected]','Alice' => '[email protected]'}
  s.source           = { :git => 'https://gitee.com/xxxx/xxxx.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/'

  s.ios.deployment_target = '9.0'
  s.swift_version = '4.2'

  
#  s.prefix_header_file = 'BLEMeshDevice/Classes/BLEMeshDevice.h'

#  temp_path = 'DemoDevice/Classes/Src'
  root_spec_path = 'BLEMeshDevice/Classes'
  current_dir = File.realpath(File.dirname(__FILE__))
  if File.file?(File.join(current_dir, "_DEV_ENV"))
    s.source_files = 'BLEMeshDevice/Classes/**/*'
    else
    make_spec_path = File.join(current_dir, "_make_spec.rb")
    File.open(make_spec_path) do |fp|
      eval(fp.read)
    end
    root_path = File.join(current_dir, root_spec_path)
    traverse(s, root_path, root_spec_path)
  end
  
  
  s.resource_bundles = {
  'BLEMeshDevice' => ['BLEMeshDevice/Assets/**/*'],
  }
  s.ios.vendored_frameworks = 'BLEMeshDevice/Products/*.framework'

  s.static_framework = true
  s.dependency 'WZPlatformKit'
  s.dependency 'ReactiveObjC', '3.1.0'


end

剩下的就是你该怎么开发你代码就怎么开发,代码都放到classes文件夹下

3.本地检化验

pod lib lint  --sources=https://github.com/CocoaPods/Specs.git,https://gitlab.favorlink.com.cn/wyze-app/wyzespec.git --use-libraries --allow-warnings --no-clean --use-modular-headers --verbose

由于我的pod版本是最新的版本,cocoapods官方要求指明共有库的地址

https://github.com/CocoaPods/Specs.git

要不然你pod install 都不会成功的,老版本的可能不需要指定,记得1.7.5的版本就不需要,重1.8.0开始官方做了改动
对以上解释如下

如果私有库添加了静态库或者dependency用了静态库需要加上

--use-libraries

想看见更详细的信息 后面加上

--verbose

忽略警告

--allow-warnings

私有库地址

--sources='xxx.git'

如果是OC和swift 的混编 加上

--use-modular-headers

4.远程验证

pod spec lint  --sources=https://github.com/CocoaPods/Specs.git,https://gitlab.favorlink.com.cn/wyze-app/wyzespec.git --use-libraries --allow-warnings --no-clean --use-modular-headers --verbose

5.创建本地私有库

pod repo add 私有库名字  索引库远程仓库地址

6.发布

#发布私有库
pod repo push 私有库名称  私有库名称.podspec

#发布公有库使用
pod trunk push  私有库名称.podspec

你可能感兴趣的:(iOS创建私有库经验总结)