使用CocoaPods创建Pod

版权声明:猴子原创,欢迎转载。转载请注明: 转载自Cocos2Der-CSDN http://blog.csdn.net/cocos2der https://blog.csdn.net/yanghuiliu/article/details/51554978

本来想给App评分,好的开源组件没有Swift版,如是自己写了个简易的。想着既然写了,就写完善点,提供给需要的人使用。这样SwiftyiRate诞生了。

下面主要说下创建pod的步骤:

一、创建github开源项目

这一步我就不细说了。

二、在本地git项目中创建podspec描述文件

1、在当前项目文件目录打开终端并执行

pod spec create YourProject

执行成功后会生成YourProject.podspec文件。该文件描述了pod项目的一些属性。

2、修改podspec文件

Pod::Spec.new do |s|
  # 你的项目名称
  s.name         = "YourProject"
  # 版本号,最后会指定到tag版本号
  s.version      = "1.0"
  # 简要描述
  s.summary      = "YourProject short summary"
  # github仓库地址
  s.homepage     = "https://github.com/YourProject/YourProject"
  # license协议
  s.license      = { :type => "MIT", :file => "LICENSE" }
  # 作者
  s.author       = { "Author Name" => "[email protected]" }
  # 是否支持arc
  s.requires_arc = true

  #  对应的平台版本号
  s.ios.deployment_target = "8.0"
  # s.osx.deployment_target = "10.7"
  # s.watchos.deployment_target = "2.0"
  # s.tvos.deployment_target = "9.0"

  # 需要提供给pod的文件git地址
  s.source       = { :git => "https://github.com/YourProject/YourProject.git", :tag => s.version }
  # 需要提供给pod的具体文件
  s.source_files  = "YourProject/*.swift"
  # 如果有资源则指定,没有的话无需该条配置
  s.resources = "YourProject/YourProject.bundle"
end

三、验证podspec文件是否正确

注意:验证前,请在github提交一个当前仓库的tag,版本号为上面podspec文件的版本号

pod spec lint YourProject.podspec

验证成功会显示

 -> YourProject (1.0)
Analyzed 1 podspec.
YourProject.podspec passed validation.

四、注册pods账号

1、注册账号

pod trunk register [email protected] 'name'

执行成功后会显示

[!] Please verify the session by clicking the link in the verification email that has been sent to [email protected]

去邮箱点击验证链接

五、提交pods

注意:如果你没有翻墙,可能会需要的时候比较久,我用了大概2分钟提交完毕

pod trunk push YourProject.podspec

成功后会显示:

 -> YourProject (1.0)

Updating spec repo `master`
  - Data URL: https://raw.githubusercontent.com/CocoaPods/Specs/xxxxxxx/YourProject.podspec.json
  - Log messages:
    - May 31st, 21:54: Push for `YourProject 1.0' initiated.
    - May 31st, 21:54: Push for `YourProject 1.0' has been pushed (2.903283301 s).

ok。到此就成功了。

pod trunk me

可以查看自己的pod账号信息

猜你喜欢

转载自blog.csdn.net/yanghuiliu/article/details/51554978