Skip to content

Commit dc7f871

Browse files
committed
update post
1 parent b91d9f4 commit dc7f871

1 file changed

Lines changed: 57 additions & 5 deletions

File tree

‎_posts/2017-03-08-CocoaPods公有仓库的创建.md‎

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,63 @@ tags:
1212
- Git
1313
---
1414

15-
> 手把手教你创建 CocoaPods 公有仓库
15+
> 本文发布于 [BY Blog](http://qiubaiying.github.io)、[简书](http://www.jianshu.com/p/d2d98298b1b8) 转载请保留链接
1616
17-
当你有一个CocoaPods的公有仓库时,别人要使用你的框架时只需要在 `Podflie` 添加一句 `pod BYPhoneNumTF` 就能轻松的导入,是不是非常棒呢。
17+
# 前言
1818

19-
下面我们将一步步把我封装的这个简单的textFiled控件 [BYPhoneNumTF](https://github.com/qiubaiying/BYPhoneNumTF) 上传到Cocoapods 公有仓库。
19+
作为iOS开发者,CocoaPods的使用为我们开发带来了极大的便利。
20+
21+
我们先来看看CocoaPods本地目录中有什么
22+
23+
$ cd ~/.cocoapods/repos/master
24+
25+
或者显示隐藏文件
26+
27+
$ defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder
28+
29+
然后进入 `~/.cocoapods/repos/master`
30+
31+
你会发现 `master` 是一个 git 仓库,输出仓库的远程地址,发现是一个GitHub仓库
32+
33+
$ git remote -v
34+
35+
origin https://github.com/CocoaPods/Specs.git (fetch)
36+
origin https://github.com/CocoaPods/Specs.git (push)
37+
38+
39+
[![](https://ww4.sinaimg.cn/large/006tKfTcgy1fdgdi59dnnj31kw10247u.jpg)]()
40+
41+
继续,我们进入`Specs`文件夹一直往里点
42+
43+
![](https://ww3.sinaimg.cn/large/006tKfTcgy1fdgdpyex7mj30yk0bkdi5.jpg)
44+
45+
你会发现很多框架以及版本号,选择一个框架,通过
46+
47+
$ pod search YYImage
48+
49+
pod搜索 Specs 文件夹中的框架,输出框架信息
50+
51+
-> YYImage (1.0.4)
52+
Image framework for iOS to display/encode/decode animated WebP, APNG, GIF,
53+
and more.
54+
pod 'YYImage', '~> 1.0.4'
55+
- Homepage: https://github.com/ibireme/YYImage
56+
- Source: https://github.com/ibireme/YYImage.git
57+
- Versions: 1.0.4, 1.0.3, 1.0.2, 1.0.1, 1.0, 0.9.5, 0.9.4, 0.9.3, 0.9.2,
58+
0.9.1, 0.9.0, 0.8.9 [master repo]
59+
- Subspecs:
60+
- YYImage/Core (1.0.4)
61+
- YYImage/WebP (1.0.4)
62+
每个版本号对应的一个json文件,描述了每个对应版本的框架的信息、配置、及源码下载地。
63+
64+
![](https://ww4.sinaimg.cn/large/006tKfTcgy1fdgdsl5tdxj318q14mdq2.jpg)
65+
66+
我们在 CocoaPods 发布我们的框架时,就是要在 `master` 仓库中添加我们的仓库描述信息,然后push到远程仓库中。不过这个过程不用我们手动去操作,只需要通过`pod`命令进行操作即可。
67+
68+
69+
下面我们将一步步把我封装的这个简单的TextFiled控件 [BYPhoneNumTF](https://github.com/qiubaiying/BYPhoneNumTF) 上传到 Cocoapods 公有仓库中。
70+
71+
# 正文
2072

2173
#### 注册 CocoaPods 账号
2274
想创建开源的Pod库,就要注册一个CocoaPods账号,我们使用终端注册, `email` 用你的 `GitHub` 邮箱
@@ -205,7 +257,7 @@ end
205257

206258
![](https://ww4.sinaimg.cn/large/006tNbRwgy1fdfkr2l7omj31kw0d7446.jpg)
207259

260+
# 结语
208261

209-
210-
262+
到此,你已经掌握了创建和维护一个Cocoapods公有仓库的技能了,是不是很棒~
211263

0 commit comments

Comments
 (0)