ios技术分享| iOS 发布 framework 到 Cocoapods 以及常见问题

29 篇文章 1 订阅
15 篇文章 0 订阅

前言

CocoaPods 是一个用来管理 Xcode 依赖库的项目,通过 CocoaPods,我们可以直观集中和
自动化地管理我们项目的第三方库。

本篇文章讲述如何将 framework 发布到 Cocoapods 以及发布中遇到的常见问题。

注册 CocoaPods 的 Trunk 服务

  1. 执行完以下命令,去邮箱点击 Trunk 验证链接。
$ pod trunk register yourEmail 'your name' --verbose

example:

pod trunk register anyrtc@dync.cc ‘anyrtc’ --verbose

  1. 查询注册信息。
$ pod trunk me

trunk me

Cocoapods 发布

常见的CocoaPods 发布使用 Github 上的 git 方式,然而 spec.source 支持 git, hg, bzr, svn and HTTP。日常开发推荐使用 git 方式。

git 方式
  spec.source = { :git => "https://github.com/anyrtc/xxx.git", 
                     :tag => "#{spec.version}",
                     :submodules => true }
  1. 创建工程

create

  1. 从 Github 上将刚创建的项目 clone 下来,使用终端进入根目录,创建
pod spec create xxx

directory

  1. 修改配置文件

spec

配置文件如何修改?详见 Cocoapods guides

spec 配置,前往 CocoaPods ,可查询所有 Cocopoads 上库的相关信息

spec

  1. 提交到 Github 仓库,目录如下:

git add .
git commit -m “commit message”
git push -u origin master
  1. 生成tag并推送,对应spec.source。
$ git tag '1.0.0'
$ git push --tags
$ git push origin master

$ pod spec lint --allow-warnings
(详细 pod spec lint xxx.podspec --verbose)

pod trunk push
或
pod trunk push xxx.podspec
或
pod trunk push xxx.podspec --allow-warnings
http 方式
  spec.source = { :http => 'https://anyrtc.com/ios/xxx.zip'}

创建修改 spec 配置文件,直接 pod trunk push

Cocoapods 发布常见问题

  1. pod trunk push 时出现如下错误:
[!] Source code for your Pod was not accessible to CocoaPods Trunk. Is it a private repo or behind a username/password on http?

http

造成这个错误的可能很多,CocoaPods issues

如果使用 spec.source 使用 http 方式导致上述错误,可能是 http 地址验证失败或添加防盗链导致,地址使用http 或 https 均可 。

  1. pod trunk push 时出现如下错误:
[!] The spec did not pass validation, due to 1 warning (but you can use `--allow-warnings` to ignore it).

解决方法

解决警告或者直接忽略

$ pod trunk push xxx.podspec --allow-warnings
  1. pod search xxx 时出现如下错误:
[!] Unable to find a pod with name, author, summary, or description matching `xxx`

解决方法

$ rm ~/Library/Caches/CocoaPods/search_index.json$ pod update
  1. pod trunk push 时出现如下错误:
[!] Validating podspec -> xxx    - ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/local/bin/git clone https://github.com/ /var/folders/y7/n65v0jv56m1_7cnw2_rgkw_40000gn/T/d20200730-14094-1fdff6i --template= --single-branch --depth 1 --branch 4.0.1Cloning into '/var/folders/y7/n65v0jv56m1_7cnw2_rgkw_40000gn/T/d20200730-14094-1fdff6i'...error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60fatal: The remote end hung up unexpectedlyfatal: early EOFfatal: unpack-objects failed) during validation.[!] The spec did not pass validation, due to 1 error.

解决方法

网上查询都是说打tag,重复几次均无效,暴力解决 -> 删除远程仓库重新提交 -> 成功。

  1. pod trunk push 时出现如下错误:
[!] Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.

解决方法

① 查询注册信息

$ pod trunk me

② pod trunk register 邮箱 名字

$ pod trunk register xxx@dync.cc yusheng

③ 查收邮件,点击邮件链接,重新提交即可。

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值