创建本地cocoapods库

一、创建spec文件

pod lib create [libName]

二、配置spec文件

[s.name](http://s.name)             = 'libName' #名字必须与libname相同
s.version          = '1.0.1' #版本必须为0.0.0格式
s.summary          = 'all gesture view' #关于库的一个简短描述
s.description      = <<-DESC
TODO: 备注文字(较长描述)
                         DESC
#是否支持arc
s.requires_arc = true
#文件主页
s.homepage         = '[https://www.google.com](https://www.google.com)'
#开源协议
s.license          = { :type => 'MIT', :file => 'LICENSE' }
#作者信息
s.author           = { 'kiyo' => '[[email protected]](mailto:[email protected])' }
#源文件所在网络路径
s.source           = { :git => '[https://github.com/xxxx/libName.git](https://github.com/xxxx/libName.git)', :tag => s.version.to_s }
#自定义framework所在路径
s.vendored_frameworks = 'xxxFrameworks/xxx.framework'
#支持版本
s.ios.deployment_target = '8.0'
#公开头文件名
s.public_header_files = 'Pod/Classes/**/*.h'
#依赖的系统框架
s.frameworks = 'UIKit', 'MapKit'
#依赖的系统静态库
s.libraries = "sqlite3.0"

#依赖的第三方库
s.dependency 'AFNetworking', '~> 2.3'
#Xcode设置
s.pod_target_xcconfig = { "OTHER_LDFLAGS" => "-ObjC -all_load" }

三、本地验证spec文件

// 本地验证
pod lib lint [libName]
// 针对无法正确找到lib.podspec
pod lib lint --source https://github.com/xxxxx/libName.git
// 忽略警告
pod lib lint --allow-warnings

四、提交到远端仓库

// cd到lib目录下
cd [libFolder]
// 由于lib已经在git版本控制下就不需要初始化,直接添加文件提交
git add -A
git commit -s -m "Initial Commit of Library"
// 添加远端仓库
git remote add origin [https://github.com/xxxx/libName.git](https://github.com/xxxx/libName.git)
// 提交到远端仓库
git push orgin master

五、远程验证spec文件

// 远端验证
pod spec lint [libName]

六、打上Tag

git tag -m "first commit" "1.0.1"
git push --tags   

七、注册发布自己的Pods(已注册跳过该步骤)

  • 注册Trunk获取推送资格
// 通过邮箱和用户名注册
pod trunk register [mail] [mailName] --description='xxx'
  • 等到到一份邮件,点击邮件中的链接后验证是否可以查到自己信息
// 验证注册是否成功
pod trunk me

八、发布到cocoapods

// 在工程根目录(包含有.podspec)   
pod trunk push libName.podspec

删除指定pod版本

pod trunk delete PODNAME VERSION

你可能感兴趣的:(创建本地cocoapods库)