第一步,创建 Git 远程仓库,仓库名为。<CLRollingCycleView>
1、登录 GitHub,首页找到 New repository 点击开始创建远程仓库。
2、为仓库做相关
配置,并点击 Create repository 开始创建,如下截图。

3、至此 Git 远程仓库创建完成,如下截图。

第二步,创建 Lib 库项目。
1、打开终端,执行 pod lib create CLRollingCycleView,开始创建。
2、为 Lib 库做相关配置,如下截图。

3、到此 Lib 库项目创建完成。

1、终端 cd 到项目所在目录。找到 CLRollingCycleView.podspec 文件,如下图。

2、终端执行命令 vim CLRollingCycleView.podspec 编辑 CLRollingCycleView.podspec 文件,如下图。

3、编辑完成 终端执行 esc :wq 回车 保存并退出编辑模式。至此 CLRollingCycleView.podspec 配置完成。
4、每当编辑过项目后应在项目目录下执行 pod install --no-repo-update --verbose 。
5、pod 严验证,终端执行 pod lib lint ,如果有出错,会明确指出哪个地方出错,按提示信息修改即可,如下图。

第四步,创建本地仓库,关联远程仓库,提交代码。
1、cd 到项目目录下。终端执行 git init 创建本地仓库,如下图。

2、关联远程仓库。
@1、首先我们终端执行 git remote -v 命令来查看是否有远程仓库关联。如下图,很可惜,并没有与远程仓库有任何关联。

@2、终端执行 git remote add origin git@github.com:XinQianLiu/CLRollingCycleView.git 后缀 “git@github.com:XinQianLiu/CLRollingCycleView.git”为 git ssh 访问。
@3、再次执行 git remote -v 如下图。

@3、至此你的本地仓库与远程仓库已经关联起来了。
3、提交代码
@1、首先终端执行 git status 查看当前状态,如下图。我这个是测试项目,没有 .h .m 文件,实际项目略有不同。这里列出了有变更的文件。

@2、继续终端执行 git add . 添加提交的文件,接着再次执行 git status 命令如下图。

@3、如图所示,绿色为所添加的文件。包括 CLrollingCycleView.podspec 文件。
@4、提交,终端执行 git commit -m “提交描述” 如下图。

@5、再次执行 git status 查看状态。如下图所说,您的工作目录很干净。我们开始往远处仓库 push。

4、Push
@1、终端执行 git pull origin master 从远处仓库拉取如下图。

@2、终端执行 git push origin master -u ,第一次提交,可加后缀 -u,如下图。

@3、打上标签,终端执行 git tag 0.0.1 接着执行 git push —tags ,如下图。

@4、登录你的 GitHub 查看你当前的远程库,如下图。


@5、至此你的项目已经提交完成了。
第五步,提交 CLRollingCycleView.podspec 到 Cocoapods 官方 Specs 仓库中。
要想一个 CLRollingCycleView 真正可以用,就得把生成的 CLRollingCycleView.podspec 文件提交到 Cocoapods 官方的Specs仓库中,才能被 search 到并使用
按照git的规则,要想向别人的仓库中添加文件,fork一份,添加修改,然后push给作者,等待审核,然而这条路已经被堵死了..
CocoaPods为我们提供了另外一个更方便安全的方法 trunk。
1、Trunk 注册,如果第一次使用的话那么就需要注册了,需要cocoapods 0.33版本以上才支持。接下来的几个步骤需要自备梯子,否则可能会够不着。
终端执行 pod trunk register *youremail*@gmail.com '*yourname*' --description='iMac' --verbose
以上命令是注册所需的,替换你的邮箱,用户名,以及描述内容, --verbose可以输入详细的debug,完成后需要去邮箱验证一下能继续往下操作。
注册成功以后,可以使用终端命令 pod trunk me 查看注册信息,以及发布过得的Pods。
2、提交 CLRollingCycleView.podspec 文件。
在 CLRollingCycleView.podspec 文件目录下执行终端命令 pod trunk push 。CLRollingCycleView.podspec 。
这条命令做了如下三件事:
@1、验证本地的 podspec 文件,也可以使用 pod lib lint 验证。
@2、上传 podspec 文件到 trunk 服务。
@3、将 CLRollingCycleView.podspec 文件转为 CLRollingCycleView.podspec.json 文件。
@4、终端执行 pod search CLRollingCycleView 就可以找到了,如果没有找到 pod setup 再试一下。
网友评论