公司里有时候我们会用到很多分类和扩展,一般会写好多文件,这是我用到的和自己收集的一些封装,为了能够好好的管理,不用开始新项目时候,把文件拖来拖去,这个时候就想到了,把这些建成自己的公开库.
1,如何在GitHub上创建自己的的项目
下面是我自己写过的这个文章,不会的可以看一下,这里创建公开库的时候,只需填写名字和简介就可,剩下的readerme
、.gitignore
和证书
都不要选,因为下面的步骤会创建的有..
GitHub项目管理
2,在桌面上的创建文件,工程
cd /Users/XXXX/Desktop //打开桌面
pod lib create XXXXXname //创建网上工程相同的名字 XXXXname是你库的名字
3,内容填写

3.1 创建项目会出现下图的情况,自己去Example --->podfile移除,再pod install
就可


4,项目结构

5 修改XXXX.podspec文件

pod lib lint(验证上一步编辑的MMBasicUIKit.podspec文件)
如果有error, 就去一个一个解决
如果有警告, 就执行pod lib lint --allow-warnings
6,进入 Example 文件目录下,执行 pod install 把你封装的代码集成到Example中.

Example下的项目文件结构:

6, 把cocoapods 项目与代码仓库关联 并且上传
9.1
重要的来了——>
git remote #查看远程仓库,正常应该是什么都没有
git remote add origin https://github.com/LYFGH/YFLBasicFoundation.git //(将本地库和远程库做关联)
git remote #查看是否成功,如果成功会出现origin
git push origin master(提交到远程库)
如果出这样的错,
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/LYFGH/YFLBasicFoundation.git'
试试下边的这样:
1. git add .
2. git commit -m '123'
3. git pull origin master
4. git push origin master
下一步打tag
git tag ‘0.1.1’(要和文件中对应)
git push --tags(将tag提交到远程)
pod spec lint --allow-warnings(验证远程时候正确, 账号密码一定要对)
如果正确的话会提示 MyProjectBase.podspec passed validation.
5,把要打成私库的代码放到YFLBasicFoundation ->Classes 下,删除replaceMe文件。

更重要的来了——>
执行pod repo查看一下
pod repo add YFLPodSpecs https://github.com/LYFGH/YFLBasicFoundation.git
再次查看pod repo看看是否添加进去了
pod repo
pod repo push YFLPodSpecs YFLBasicFoundation.podspec(将podspec文件提交到私有库索引, 这样别人才能pod)
提交成功后, 查看远程私有库多了一个下图的文件
10.1,打tag
//为git打tag,
git tag "0.0.1"
//将tag推送到远程仓库
git push --tags
如果我们的tag打错了,没有用的话,我们应该怎么删除呢?
1、查看tags,就会罗列出我们所有的tags
git tag
2、删除本地tags
git tag -d + 分支名称就会删除本地的分支
3、删除远程分支
git push origin :refs/tags/分支名称 就删除了远程分支

相关文章推荐:
CocoaPods创建自己的公开库、私有库
ios项目-利用Pod进行组件化开发
希望对您有所帮助
网友评论