使用swift3创建自己的pod

本文详细介绍如何使用CocoaPods进行iOS项目的依赖管理,包括注册账号、创建及配置podspec文件、验证并推送组件到公共仓库等步骤。

1>注册这台MAC可以发布POD

$ pod trunk register targetcloud@163.com "targetcloud"

[!] Please verify the session by clicking the link in the verification email that has been sent to targetcloud@163.com

去邮箱点击一下验证链接,出现下面页面表示通过



2>查看自己的信息

$ pod trunk me 

  - Name:     targetcloud

  - Email:    targetcloud@163.com

  - Since:    March 3rd, 02:13

  - Pods:     None

  - Sessions:

    - March 3rd, 02:13 - July 9th, 02:31. IP: 112.64.216.106


3>查看可以使用的组件名

$ pod search TGLabel

Creating search index for spec repo 'master'.. Done!

[!] Unable to find a pod with name, author, summary, or description matching `TGLabel`


4>创建仓库、创建工程


github创建仓库后,复制链接到SourceTreeXcode创建工程TGLabelDemo,同级目录创建TGLabel

$ cd /Users/targetcloud/Desktop/TGLabel/TGLabelDemo 

$ ls

TGLabelDemo TGLabelDemo.xcodeproj


5>创建podspec

$ pod spec create https://github.com/targetcloud/TGLabel


6>修改podspec

Pod::Spec.new do |s|

  s.name         = "TGLabel"

  s.version      = "0.0.1"

  s.summary      = "TGLabel"

  s.homepage     = "https://github.com/targetcloud/TGLabel"

  s.license      = "MIT"

  s.author       = { "targetcloud" => "targetcloud@163.com" }

  s.platform     = :ios, "8.0"

  s.source       = { :git => "https://github.com/targetcloud/TGLabel.git", :tag => s.version }

  s.source_files  = "TGLabelDemo/TGLabel/**/*.{swift,h,m}"

  s.requires_arc = true

end


7>支持swift3

$ echo 3.0 > .swift-version


8>倒数第二步,用于检查是否可以push了

$ pod spec lint


 -> TGLabel (0.0.1)


Analyzed 1 podspec.


TGLabel.podspec passed validation.


9>最后一步,用于push

$ pod trunk push


[!] Found podspec `TGLabel.podspec`

Updating spec repo `master`


坑点:pod spec lint对s.source_files的检查并不仔细,会导致验证虽然通过了,但是到了pod trunk push仍然会出错,常见的错误如下

[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down
[!] There was an error pushing a new version to trunk: Net::OpenTimeout



多次pod trunk push并不解决问题的情况下,需要检查s.source_files等项目是否符合预期!!!也可以尝试重新注册帐号、重新创建github仓库和项目来解决问题!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值