第一步:
在gitHub上创建一个新的仓库
仓库地址假设为:
git clone git@github.com:Damonvvong/DWCategory.git
第二步:
在自定义三方库文件夹中执行
git init
第三步:
将gitHub远程仓库clone到将本地三方库文件夹里
git clone git@github.com:Damonvvong/DWCategory.git
第四步:
创建本地文件和远程git仓库的联系
git remote add 项目别名 git clone git@github.com:Damonvvong/DWCategory.git
第五步:
将本地三方库代码加入本地脱管
git add .
git commit . -m “第一次提交的描述”
第六步:
将本地托管的项目同步到远程gitHub库上
git push reuseCell master
第七步:
创建 podspec 文件
pod spec create 别名 git@github.com:Damonvvong/DWCategory.git
第八步:
修改 podspec 文件
- 编写 podspec 文件
```
Pod::Spec.new do |s|
s.name = "DWCategory" #名字
s.version = "0.1.0" #版本号
s.summary = "Custom Category" #简短的介绍
s.homepage = "https://github.com/Damonvvong/DWCategory" #主页,这里要填写可以访问到的地址,不然验证不通过
s.license = "MIT" #开源协议
s.author = { "Damonwong" => "coderonevv@gmail.com" } #作者信息
s.social_media_url = "http://weibo.com/damonone" #多媒体介绍地址
s.platform = :ios, "7.0" #支持平台及版本
s.source = { :git => "https://github.com/Damonvvong/DWCategory.git", :tag => s.version } #项目地址,这里不支持ssh的地址,验证不通过,只支持HTTP和HTTPS,最好使用HTTPS,
s.source_files = "DWCategory/**/*" #代码源文件地址,**/*表示Classes目录及其子目录下所有文件,如果有多个目录下则用逗号分开,如果需要在项目中分组显示,这里也要做相应的设置
s.requires_arc = true #项目是否使用 ARC
end
我的例子:
Pod::Spec.new do |s|
s.name = "CellReuseCategory"
s.version = "0.0.1"
s.summary = "重用cell的分类"
s.description = "一个简便的重用cell的分类"
s.homepage = "https://github.com/zhch1991/cellReuseCategory"
s.license = "MIT"
s.author = { "zhch1991" => "zhch_1991@163.com" }
s.social_media_url = "http://weibo.com/damonone"
s.platform = :ios, "7.0"
s.source = { :git => "https://github.com/zhch1991/cellReuseCategory.git", :tag => s.version }
s.source_files = "UITableViewCell+initcell.m","UITableViewCell+initcell.h"
s.requires_arc = true
end
特别注意:类似ARC这种,要把前面的注释符号#打开,才能生效,否则会出现很多错误
第九步:
将刚创建修改过的podspec 文件添加到git本地库中管理
git add .
提交到本地
git commit -m "reuse Cell Category”
同步到远程gitHub代码托管服务器
git push reuseCell master
第十步:
创建发布版本文件,版本号要和podspec文件中保持一致
git tag -m "first release" 0.0.1
第十一步:
检查 podspec 文件是否编写正确。
pod lib lint
如果有提示你用—allow-warnings,就执行以下这句代码
pod lib lint —allow-warnings
第十二步:
把自己的库上传给Cocopods
[1]注册
pod trunk register zhch_1991@163.com 'zhch1991' —verbose
- 自己的邮箱
- 用户名(最好和.podspec 文件 中一样)
[2].检查是否注册成功
- 登录邮箱,确认注册
- 检查注册情况:pod trunk me(看到类似下面,就是成功了)
pod trunk me
- Name: Damonwong
- Email: coderonevv@gmail.com
[3].上传DWCategory.podspec 到 Cocoapods/repo
- 进入 文件所在文件夹
cd /Users/damon/Desktop/DWCategory
- 上传文件
pod trunk push DWCategory.podspec
[4].上传完成,查找一下
pod search DWCategory
![Succeed](http://7xlv6p.com1.z0.glb.clouddn.com/Category_Succeed.png)
> 下面就可以通过编写Podfile 文件,利用 Cocoapods 集成自己写的文件了
platform :ios, "6.0"
pod 'DWCategory'
#Done!