当我们需要发布一个自己的库到Cocoapods或者 需要修改一个三方库作为自己的私有库时,我们就需要创建一个属于自己的Podspec
准备工作,在创建一个上创建一个tag
$ git tag -a 0.0.1 -m "0.0.1"
$ git push --tags
第一步,根据git创建一个 .podspec 文件
$pod spec create https://github.com/zevwings/ZActivityIndicatorView.git
第二步,编辑 .podspec 文件,最终内容大概为:
Pod::Spec.new do |s|
s.name = "ZActivityIndicatorView"
s.version = "0.0.1"
s.summary = "a simple indicator for swift "
s.description = <<-DESC
a simple indicator for swift and simple to use.
DESC
s.homepage = "https://github.com/zevwings/ZActivityIndicatorView"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "zevwings" => "zev.wings@gmail.com" }
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/zevwings/ZActivityIndicatorView.git", :tag => "0.0.1" }
s.source_files = "ZActivityIndicatorView/*.swift", "ZActivityIndicatorView/ZActivityIndicatorView.h"
# s.exclude_files = "Classes/Exclude"
# s.resources = "Resources/*.png"
s.requires_arc = true
# s.dependency "JSONKit", "~> 1.4"
end
第三步,验证 .podspec 是否可用
$ pod spec lint ZActivityIndicatorView.podspec
验证失败会抛出错误,根据错误做相应的修改。
第四步,上传 .podsepc 到你的git
$ git add ZActivityIndicatorView.podspec
$ git commit -m "upload podspec"
$ git push origin master
第五步,用邮箱注册一个Cocoapods账号
$ pod trunk register zev.wings@gmail.com 'zevwings' --description='zev wings cocoapods'
第六步,发布你的.podspec 到 Cocoapods
$ pod trunk push ZActivityIndicatorView.podspec
最后,我们搜索我们发布到Cocoapods的Podspec
$ pod search ZActivityIndicatorView
结果如下图内容所示: