iOS 自己的工程 cocoapods

2020-08-08  本文已影响0人  帅气的阿斌

让自己的工程支持cocoapods 大概流程如下
1.上传自己的工程到github
2.在github上release出一个版本
3.注册cocoapods账号
4.配置podspec,通过podspec配置信息将github的代码传到cocoapods

3.pod trunk register 邮箱地址 '用户名' --description='描述信息'
验证注册是否成功
pod trunk me

4.配置podspec文件

Pod::Spec.new do |spec|
  #工程名称
  spec.name             = "BinSwipeCell"
  #版本号 spec.source中引用了该信息作为github上release的版本号
  spec.version          = "1.0.0"

  #简单描述
  spec.summary          = "为SWTableViewCell 添加了左右间距功能"
  #详细描述
  spec.description      = <<-DESC
                        - 项目源于SWTableViewCell.
                        - 为SWTableViewCell 添加了左右间距功能.
                        DESC

  #与项目相关的首页
  spec.homepage         = "https://github.com/iBinbro/BinSwipeCell"
  #授权文件类型和路径 这里指向更目录下的LICENCE文件
  spec.license          = { :type => "MIT", :file => "LICENCE" }
  spec.author           = { "iBinBro" => "812117956@qq.com" }
  spec.social_media_url = "https://www.binsama.com"
  spec.platform         = :ios, "8.0"
  #github的路径以及tag
  spec.source           = { :git => "https://github.com/iBinbro/BinSwipeCell.git", :tag => "#{spec.version}" }
  #项目中用来作为工具的文件路径
  spec.source_files     = "Classes/**/*.{h,c,m,mm}"
  #该项目正常使用需要的框架
  spec.frameworks       = [ "Foundation", "UIKit"]
  #spec.libraries        = [ "z", "sqlite3" ]
  spec.requires_arc     = true
  #spec.compiler_flags   = "-Wno-unsupported-availability-guard -Wno-strict-prototypes"
  #头文件
  spec.public_header_files = [ "Classes/*.h", "Classes/SWTableViewCell/*.h"]
end

预先校验信息是否正确
pod spec lint

上传项目至cocoapods;allow-warnings表示运行有警告的情况下继续上传项目

pod trunk push 你的配置文件.podspec --allow-warnings

更新本地仓库信息
pod repo update
更新完成后pod search binswipecell并不能搜到
所以要在工程 podfile 中直接添加,然后pod install 即可

pod 'BinSwipeCell', '1.0.1'

配置中常见的问题可看别人的总结
常见问题汇总

上一篇下一篇

猜你喜欢

热点阅读