02. 自定义pod创建

2018-05-03  本文已影响0人  契约工程师

1. POD库的创建

  1. 首先创建本地的文件,cd 到这个文件下

  2. pod lib create xxx

//这里xxx是pod的name,自己取名
除了第一个是yes,其他都选择no,这里会创建模板

  1. 打开模板,在pods -> Development Pods 里面的名称目录拖进去,可以和class同级目录,这里主要对象是framework,如果是具体的实现文件,建议放到classes里面

了解: https://www.cnblogs.com/ALongWay/p/6541289.html

了解: https://guides.cocoapods.org/syntax/podspec.html#watchos


#
# Be sure to run `pod lib lint ToolTest1.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 http://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  #这里是搜索POD的名称
  s.name             = 'ToolTest1'
  #这里是版本号,通过这个版本在搜索下面的tag,所以版本和tag不要相同,每次都要修改这里
  s.version          = '0.0.2'
  #概述,这里必须要修改
  s.summary          = 'create by jixiao as Test'

# 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!

  #具体的描述  todo 后面的内容 必须比summary长
  s.description      = <<-DESC
TODO: create by jixiao as Test.Just For Funssssssss.
                       DESC
  #主页地址,必须要修改!!,不修改通不过
  s.homepage         = 'https://www.baidu.com'
  #默认的MIT好像是一种证书
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  #创建的时候自动生成了
  s.author           = { 'jixiao' => 'jixiao@otctop.com' }
  #来源地址,本地创建的地址,tag就是后面要打的tag
  s.source           = { :git => 'git@10.0.50.71:/home/git/zzjs.git', :tag => s.name.to_s+'v'+s.version.to_s }
  #支持的版本
  s.ios.deployment_target = '8.0'
  
  s.requires_arc = true
  
  #重要,将需要打包的framework附上,用”,”分割,或者用或者用 "*.framework"
  s.ios.vendored_frameworks = 'ToolTest1/HomeFramework.framework'
  
  # 引用自己生成的.a文件 
  # s.ios.vendored_libraries = 'Pod/Assets/*.a'
  
  #重要,第三方依赖库,如果有依赖在这里添加,如果多个需要填写多个s.dependency
  s.dependency 'AFNetworking', '~> 3.1.0'
  #所需的framework,多个用逗号隔开
  s.frameworks = 'UIKit',
  
  # 引用静态库:’(.ios).library’,去掉头尾的lib,引用libxml2.lib和libz.lib.
  # s.libraries =  'xml2', 'z'
  
  # 载入bandle
  s.resources     = "TGRefreshOC/TGRefreshOC/TGRefreshOC/TGRefreshOC.bundle" 
  # s.resources = ["Images/*.png", "Sounds/*"]
  
  # s.resource_bundles = {
  # 'MyLibrary' => ['Resources/*.png'],
  # 'OtherResources' => ['OtherResources/*.png']
  
  # 关于引入module 需要下面的话,没有测试过
  s.preserve_path = 'module/module.modulemap'
  s.module_map = 'module/module.modulemap'

  s.pod_target_xcconfig = { 'HEADER_SEARCH_PATHS' => '$(PODS_ROOT)/mypod/module' }
  s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2 $(PODS_ROOT)/mypod/module' }
  
}

end



2. podspec 上传到私有仓库

  1. cd 到含有podspec的文件下
  2. 编辑podspec ,具体看上面部分
  3. 编辑完成pod lib lint/pod spec lint --sources='私有仓库repo地址,https://github.com/CocoaPods/Specs' --use-libraries 检查是否能通过
  4. 检查完成git add -A && git commit -m "这是comence信息"
  5. git tag '[Pod的名字]v0.0.1'
  6. git remote add 仓库名 仓库地址
  7. git push 仓库名 --tags
  8. pod repo push 仓库名 NAME.podspec

参考文档

http://www.jianshu.com/p/1e5927eeb341

上一篇下一篇

猜你喜欢

热点阅读