美文网首页
如何建立自己的公有pod

如何建立自己的公有pod

作者: 雪_晟 | 来源:发表于2017-11-08 17:26 被阅读23次

如果在开发过程中,想把自己封装的一些控件、分类打包以pod的形式供自己或团队使用,我们可以建立公有pod或者私有pod。

以下指示介绍如何打包公有pod供自己使用。

步骤 1.
前往githup建立库。

cocoapods.png

选择MIT 认证(得到cocopods的认证许可。)

接下来把你需要的上传的工具类放到目录下:


目录.png

步骤二:

创建.podspec文件。
LXUtils 是你新建库的名字。

pod spec create LXUtils

执行完上面的命令,会生成一个.podspec的文件。

可以编辑打开,我是通过webStorm打开的(不知道为什么,通过默认的编辑器打开后面进行spec文件验证的时候经常提示语法错误,所以建议还是通过工具打开吧):

最好还是根据里面的修改。切记tag选项前面必须添加v

s.name         = "LXUtils"
 s.version      = "0.0.1"
 s.summary      = "common tools on iOS."
s.description  = <<-DESC
                common tool and category on iOS
                   DESC
  s.homepage     = "https://github.com/liuxinixn/LXUtils"
s.license      = "MIT"
 s.author             = { "miss李" => "missli_211@163.com" }
s.platform     = :ios, "8.0"

s.source       = { :git => "https://github.com/liuxinixn/LXUtils.git", :tag => "v#{s.version}" }

s.source_files  = "LXUtils", "LXUtils/**/*.{h,m}"
s.framework  = "UIKit"
  s.requires_arc = true

修改好对应的选项之后,验证spec文件的合法性。

pod lib lint LXUtils.podspec
验证.png

步骤3.

绑定tag,然后发布。

git tag '0.0.1'  
git push --tags  
git push origin master

下面的命令需要你去邮箱进行验证

pod trunk register jiushu0228@163.com 'LXUtils'
pod trunk me

验证结果


邮箱验证.png

如果出现下面的问题:

[!] The spec did not pass validation, due to 1 error.
[!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a `.swift-version` file to set the version for your Pod. For example to use Swift 2.3, run: 
    `echo "2.3" > .swift-version`.

执行echo "2.3" > .swift-version即可。

最后一步,发布spec到cocoapods

pod trunk push LXUtils.podspec

成功后如下:

zhongzhideMini:LXUtils chenergou$ pod trunk push LXUtils.podspec
Updating spec repo `master`

CocoaPods 1.3.0.beta.3 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.3.0.beta.3

Validating podspec
 -> LXUtils (0.0.1)

Updating spec repo `master`

CocoaPods 1.3.0.beta.3 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.3.0.beta.3


--------------------------------------------------------------------------------
 🎉  Congrats

 🚀  LXUtils (0.0.1) successfully published
 📅  November 8th, 02:45
 🌎  https://cocoapods.org/pods/LXUtils
 👍  Tell your friends!

补充

提交后需要等一段时间,如果搜不到试试下面的方法:
根据路径~/Library/Caches/CocoaPods/search_index.json找到这个json文件,然后删除即可。

重新'pod search LXUtils'

输出:Creating search index for spec repo 'master'.. Done!,稍等片刻就会出现所有带RxSwift字段的类库出现。

如何更新pod

1.升级版本

git tag 'v0.0.2'  
git push --tags  
git push origin master

2.更新到cocoapods

pod trunk push LXUtils.podspec

成功之后,如果搜索不到执行pod setup

总结

主要命令:

git tag 0.0.1   //打tag
git push --tags //推送tag到远程
git push origin master 
pod lib lint//验证spec文件的合法型
pod trunk push LXMUtils.podspec //推送spec

pod trunk register xxx@163.com 'userName' --verbose //每次注册新的仓库必须验证一次
pod trunk me//验证结果
git tag -d 0.0.1 //移除某个tag
git push origin :refs/tags/0.0.1 //远程移除某个tag

相关文章

  • 如何建立自己的公有pod

    如果在开发过程中,想把自己封装的一些控件、分类打包以pod的形式供自己或团队使用,我们可以建立公有pod或者私有p...

  • 组件

    上传pod的公有库 pod trunk push 自己的spec --verbose上传自己私有库 pod r...

  • 组件化开发之-pod创建规范

    原创 2017-05-09 关键点:公有Pod仓库创建私有Pod的创建规范如何开发及部署你的pod 这里仅以公司一...

  • 建立pod仓库

    一 公有仓库 1.建立工程1.1 首先github建立一个工程1.2 将远程项目clone到本地 创建 pod 库...

  • 制作Pod库

    目录 一、公有Pod库制作 二、私有Pod库制作 三、subspec子库的制作 四、遇到的坑 一、公有Pod库制作...

  • 创建 pod仓库 submodule subtree

    创建公有pod仓库私有仓库浅谈iOS工程依赖submodule subtree pod管理

  • iOS - 制作私有Pod库

    一、公有Pod库 公有Pod库大家应该都比较熟悉,项目中经常使用的三方库,如AFNetworking,Masonr...

  • pod 公有库

    前言 CocoaPods 的使用是每一个 iOS 开发者必备的技能,我们平时都是使用别人的第三方库,那如何组件化自...

  • 制作自己的Pod库(公有/私有)

    目的:1.管理自己常用的类;2.组件化开发 步骤: 1.想一个比较酷的名字,在桌面简历文件夹。 2.打开termi...

  • 创建远程pod公有库

    前言: 关于创建自己的远程pod公有库, 使得能在开发中可以利用pod来管理自己的库, 例如一些在iOS开发中常用...

网友评论

      本文标题:如何建立自己的公有pod

      本文链接:https://www.haomeiwen.com/subject/yleymxtx.html