记录CocoaPods公有库提交

394 阅读2分钟

1.注册CocoaPods账号

打开终端输入  user_email 你的邮箱 user_name你的用户名

pod trunk register user_email 'user_name' --verbose

然后等待出现如下提示时去你的邮箱进行验证

Please verify the session by clicking the link in the verification email that has been sent to you_email

最后在输入

pod trunk me

来查看注册信息

2.创建Git仓库

在Git上创建一个公开项目(GitHub|码云)上创建都行

  • 项目中需要包括FILE_LICENSE:开源许可证

如果没有可以自己创建通过终端输入touch  FILE_LICENSE

Copyright (c) 2016-2019 项目名 (地址) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 

  • REAME.md:说明
  • CocoaPods.podspec:CocoaPods 的描述文件,这个文件非常重要
  • 你的代码(需要注意路径)

 2.1创建.podspec

pod spec create MyDemo

打开仓库下的.podspec文件修改其中的信息

Pod::Spec.new do |s|
  s.name         = "MyDemo" # 项目名称  s.version      = "0.0.2"        # 版本号 与 你仓库的 标签号 对应
  s.license      = "MIT"          # 开源证书
  s.license      = { :type => "MIT", :file => "FILE_LICENSE" }
  s.summary      = "这里是简介" # 项目简介
  s.description  = <<-DESC 
                         这里是描述                   DESC
  s.homepage     = "https://github.com/aiyouBug/MyDemo" # 你的主页  s.source       = { :git => "https://github.com/aiyouBug/MyDemo.git", :tag => "#{s.version}" }#你的仓库地址,不能用SSH地址  s.source_files = "Classes/MyDemo/*.{h,m}" # 你代码的位置, Classes/*.{h,m} 表示 Classes 文件夹下所有的.h和.m文件  s.requires_arc = true # 是否启用ARC
  s.platform     = :ios, "9.0" #平台及支持的最低版本
  s.frameworks   = "UIKit", "Foundation" #支持的框架
  # s.dependency   = "AFNetworking" # 依赖库
  
  # User
  s.author             = { "MyDemo" => "MyDemo@163.com" } # 作者信息  s.social_media_url   = "https://github.com/aiyouBug" # 个人主页

end

目录如下



3.上传到Git

git add .git common -m "初始化"

4.打Tag(tag需要和podspec的版本一致否则会报错)

git tag "v0.0.1"
//将tag推送到远程仓库
git push --tags

5.验证.podspec

pod spec lint MyDemo.podspec --verbose

忽略警告:pod lib lint --allow-warnings

6. 发布

pod trunk push MyDemo.podspec

然后等待一会再去查询是否发布成功

7.验证仓库

pod search MyDemo.