最近在学习项目组件化,想把自家公司的项目优化一下,学习了很多网上的教程,也不能说没用,只是我陷入了一个误区,经过无数坑的洗礼,宋同事和我总结出一套的想法.podspec要和组件库分开经验证是可行的
第一,建立一个存放.podspec的私有库,我这里就命名为mySpec,如下图

创建好如下图

我们建的的这个mySpec的库千万不要往里边传代码,只传.podspec文件(方法后边会用到这个方法 pod repo push *** ****.podspec --allow-warnings)
执行命令:
pod repo add mySpec https://github.com/MaShiYongIsBoy/mySpec.git
终端如下图

前往文件夹,看看我们的mySpec库
~/.cocoapods/repos

里边会有两个,一个是pod的master一个是我们自己的mySpec
第二步,请不要想第一步的事情,接下来又是一块独立的:
1、在git上建一个私有组件库,我们命名为privateLib如下图


2、接下来建一个本地的组件库命名和git上的一样 privateLib,我们建一个lib的文件夹,来放置我们本地的私有库

命令如下:
cd 到lib文件夹

pod lib create privateLib


cd到privateLib文件加下

依次执行如下命令
git init
git add .
git commit -m "init"
git remote add origin https://github.com/MaShiYongIsBoy/privateLib.git
git push origin master -f

我们就把我们建的组件库传到了git

打版本号
git tag 0.1.0
git push --tags

关键的一步,把podspec和组件库分开
pod repo push mySpec privateLib.podspec --allow-warnings

分别是我们的第一步和第二步建立的私有库
这样cocopod创建私有库就完成了之后我们会更新,使用我们的组件库(私有库)
最后看一下 成果
前往文件夹
~/.cocoapods/repos

网友评论