【从简】向CocoaPods提交自己的框架
2016-11-08 本文已影响78人
SevenJustin
古话说:赠人玫瑰,手留余香。帮助别人是一件让需要帮助的人和自己快乐的事情。我们需要把自己的经验所得介绍分享给他人这样这笔财富才会显得更有价值。今天的主题是教你如何把自己的框架分享到CocoaPods上,让广大的开发者们一同受益。
第一步 GitHub端仓库
选择创建新的仓库

注意选择MIT协议

第二步 本地端
1 从GitHub项目地址拷贝到电脑端 注意项目地址来源于并执行

git clone https://github.com/SevenJustin/FirstCocoaPodsTest.git
2 根目录下创建CocoaPods的配置文件后并打开修改
pod spec create FirstCocoaPodsTest
修改内容可参考
Pod::Spec.new do |s|
s.name = "FirstCocoaPodsTest"
s.version = "1.0.0"
s.summary = "A short description of FirstCocoaPodsTest."
s.description = <<-DESC
It is a marquee view used on iOS, which implement by Objective-C.so what can i do to tell you that this specfication is valid now.
DESC
s.homepage = "https://github.com/SevenJustin/FirstCocoaPodsTest"
s.license = "MIT"
s.author = { "你的大名" => "你的大名邮箱@163.com" }
s.platform = :ios, "7.0"
s.source = { :git => "https://github.com/SevenJustin/FirstCocoaPodsTest.git", :tag => "1.0.0" }
s.source_files = "UCSPodsButton/*" *你要共享的文件目录*
s.frameworks = 'Foundation', 'CoreGraphics', 'UIKit'
s.requires_arc = true
end

3 把你要分享的源文件目录拷贝到根目录 并创建一个Demo使用。最后你的目录应该类似这样

4 验证CocoaPods并提交本地代码到GitHub
//为pod添加版本号并打上tag
set the new version to 1.0.0
set the new tag to 1.0.0
pod lib lint
//如果报错是 - WARN | summary: The summary is not meaningful. 可以用下面的语句忽略
pod lib lint --allow-warnings
//如果正常会反馈给我们
FirstCocoaPodsTest passed validation.
//接下来就可以提交代码了 命令注意区分大小写
git add -A && git commit -m "提交说明自定义如:1.0.0终于发布了."
git tag '1.0.0'
git push --tags
git push origin master
到此处刷新你的github仓库应该就会有你刚刚提交的内容了
第三步 提交PodSpec给CocoaPods官仓
CocoaPods官仓地址
Specs中包含了所有我们能用pod search
搜索到的全部Pods依赖库关联的podspec
文件,所以我们需要将我们刚刚做好的podspec文件上传到官仓中。
接下来我们先fork一份该仓库到自己的repository中以便做修改,之后将修改的内容提交并像官仓pull request等待审核最后添加。
1 fork之后拷贝到本地
git clone https://github.com/wangzz/Specs.git
2 在官仓的目录中新建并拷贝podspec文件到指定位置 规则为如下:
Pods依赖库同名文件夹--->版本号同名文件夹--->podspec文件
git add -A && git commit -m "添加 podspec file"
git push origin master
3 作出修改之后需要在github中提交你的修改给官仓


到此就算是上传完成了 接下来就等待吧 审核进度查询
4 审核通过以后
//它会将所有的Pods依赖库tree跟新到本地
pod setup
pod search FirstCocoaPodsTest
然之后就尽情享受这个自己制作上传的框架给他人带来的快感吧!!