CocoaPods创建公共库

  • GitHub新建自己的git repository

  • 将项目clone到本地

git clone git@github.com:xxx/xxx.git
  • 初始化好项目,将Pod库文件建立好目录
PodFileDirectory.png
  • 给仓库创建个podspec文件
pod spec create xxx git@github.com:xxx/xxx.git
CreatePodSpec.png
  • 编写xxx.podspec文件

项目中不做子目录分层显示

Pod::Spec.new do |s|
s.name             = "xxx"
s.version          = "0.0.6"
s.summary          = "Custom Category used on iOS."
s.description      = <<-DESC
                     Custom Category used on iOS, which implement by Objective-C.
                     DESC
s.homepage         = "https://github.com/xxx/xxx"
s.license          = 'MIT'
s.author           = { "xxx" => "xxx@gmail.com" }
s.platform         = :ios, '7.0'
s.source           = { :git => "https://github.com/xxx/xxx.git", :tag => s.version }
s.source_files     = 'xxx/**/*'
s.requires_arc     = true
end

项目中做子目录分层显示

Pod::Spec.new do |s|
  s.name             = "xxx"
  s.version          = "0.0.6"
  s.summary          = "Custom Category used on iOS."
  s.description      = <<-DESC
                       Custom Category used on iOS, which implement by Objective-C.
                       DESC
  s.homepage         = "https://github.com/xxx/xxx"
  s.license          = 'MIT'
  s.author           = { "xxx" => "xxx@gmail.com" }
  s.platform         = :ios, '7.0'
  s.source           = { :git => "https://github.com/xxx/xxx.git", :tag => s.version }
  s.requires_arc     = true

# UIView 和 EasyLog 在工程中以子目录显示
  s.subspec 'UIView' do |ss|
    ss.source_files = 'xxx/UIView/*.{h,m}'
  end

  s.subspec 'EasyLog' do |ss|
    ss.source_files = 'xxx/EasyLog/*.{h,m}'
  end
  
end

s.source_files = ' ' 的多种写法

s.source_files = 'xxx/UIView/*.{h,m}'

表示xxx/UIView/目录下的所有.h和.m文件


s.source_files = 'xxx/**/*'

表示xxx/目录下所有文件,包括子目录下所有文件。 **/*表示递归

当有多个文件时,应用,隔开

s.source_files = 'MMDrawerController/MMDrawerController.{h,m}', 'MMDrawerController/UIViewController+MMDrawerController*'

  • 把当前版本上传到GitHub,并打上tag(版本号) 即tag => s.version 并确保tag push到GitHub
git push origin --tags
PushTags.png
  • 检查xxx.podspec文件是否编写正确
pod lib lint
CheckPodSpec.png
  • 将xxx.podspec文件上传给CocoaPods

pod Trunk 注册

pod trunk register xxx@gmail.com  'xxx'

检查成功与否,登录邮箱,点击确认,终端输入:

pod trunk me
PodTrunk.png
  • 上传xxx.podspec 到 CocoaPods/repo
pod trunk push xxx.podspec
  • 检测是否上传成功
pod search xxx
PushSearchCheck.png

参考:

如何制作自己的Pod库

Guides Cocoapods

MMDrawerController

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容