美文网首页
CocoaPods上提交公开库详解

CocoaPods上提交公开库详解

作者: 窗内户外 | 来源:发表于2018-03-28 17:32 被阅读0次

github上的步骤: https://github.com/Damonvvong/DWCategory

一、在自己的gitHub官网上已经创建好自己的库如下:


image.png

将这个库 克隆到桌面,使用命令:

    $: cd desktop
    $: git clone https://github.com/genghongkai/HKCycleTableView.git

https://github.com/genghongkai/HKCycleTableView.git 它是从点击上图红色框内按钮,复制。

可以看到:


image.png

在find 中,文件目录:


image.png

这里说明下:HKCycleTableView仅仅是测试往CocoaPods上提交自己的库。

二、初始化项目

(1)使用命令如下:查看项目状态,确保项目是最新的。

     $: git status

(2)为项目添加 tag

    //这里0.0.2一定要和文件
    $: git tag -m "2rd release" 0.0.2
     0.0.2 就是tag,一定要与HKCycleTableView.podspec中的 tag 一致。
     $: git push --tags

三、创建和编写podspec [最重要的一步]

(1)终端中进入到正确的目录下:

    $: cd desktop/HKCycleTableView/HKCycleTableView

这里啰嗦一句:HKCycleTableView.podspec 文件一定是在上面第三个截图中,同样的目录下,不然报错。

(2)创建文件HKCycleTableView.podspec

    $: touch HKCycleTableView.podspec

(3)打开文件

    $: open -e HKCycleTableView.podspec

把下面的内容复制到自己的 HKCycleTableView.podspec中。

    Pod::Spec.new do |s|
    s.name = "HKCycleTableView"
    s.version = "0.0.2"
    s.summary = "添加测试HKCycleTableView"
    s.description = <<-DESC
            添加测试HKCycleTableView的工具
    DESC
    s.homepage = "https://github.com/genghongkai/HKCycleTableView"
    s.license = { :type => "MIT", :file => "LICENSE" }
    s.author = { "genghongkai" => "1159538747@qq.com" }
    s.platform = :ios, "7.0"
    s.source = { :git => "https://github.com/genghongkai/HKCycleTableView.git", :tag => "0.0.2" }
    s.source_files = "HKCycleTableView", "HKCycleTableView/**/*.{h,m}"
    s.framework = "UIKit"
    s.framework = "XCTest"
    end

上面的内容是什么意思,参考:https://blog.csdn.net/wang631106979/article/details/62527363

(4)保存文件,使用快捷键command + s

(5)在终端中提交 项目到github仓库。

    $: git add .
    $: git commit -m "提交podspec文件"
    $: git push

(6) 验证文件

    $: pod spec lint

(7)注册

参考:https://github.com/Damonvvong/DWCategory 这里文档中的注册部分。

(8)提交库

    $: pod trunk push
    或者:$: pod trunk push --allow-warnings

遇到问题:

(1)- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use --verbose for more information.

原因:你的工程不正确,有问题,需要你自己编译工程查找问题。

解决办法:clean下工程,重新编译下,保证工程没有错误,能运行。每次使用命令:pod spec lint 都需要确保本地工程和github上仓库内容一致,可以通过 git status 查看本地工程状态。

(2)- WARN | url: There was a problem validating the URL https://github.com/genghongkai/HKCycleTableView.

原因:未知

解决办法:

    $: pod spec lint --allow-warnings
image.png
(3)[!] CocoaPods was not able to update the master repo. If this is an unexpected issue and persists you can inspect it running pod repo update --verbose

解决办法:

    $: pod repo update

    更新后重新执,$: pod trunk push --allow-warnings

出现如下结果表示成功:

image.png
(4)[!] Unable to find a pod with name, author, summary, or description matching hkcycletableview

解决办法:

    $: pod setup //重置设置
    $: sudo gem install cocoapods //重新安装
    $: rm ~/Library/Caches/CocoaPods/search_index.json //删除搜索缓存
    $: pod search HKCycleTableView
image.png

相关文章

网友评论

      本文标题:CocoaPods上提交公开库详解

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