通常我们在开发过程中都会剥离一些组件,个人开发的时候我们大部分都用本地私有库,但是如果是多人开发的时候,本地私有库就不再适合了,那么今天我们就一起创建一个属于自己的远程私有库
创建自己的私有库
1,在码云创建两个项目,一个专门存储Spec
,一个存储项目的HelloWorld
。

2,pod lib create LQHelloWorld
创建模板

3,将创建好的测试工程提交到本地仓库
- 1.$ cd /Users/ioskaifa/Desktop/LQHelloWorld
- 2.$ git status
- 3.$ git add .
- 4.$ git commit -m'基础组件测试工程'
4,关联好之后修改Spec文件

Pod::Spec.new do |s|
s.name = 'LQHelloWorld'
s.version = '0.1.0'
s.summary = 'LQHelloWorld.'
s.description = "LQHelloWorld.Desc"
s.homepage = 'https://gitee.com/lq326065285'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'lq326065285@163.com' => '814472485@qq.com' }
s.source = { :git => 'https://gitee.com/lq326065285/LQHelloWorld.git', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.source_files = 'LQHelloWorld/Classes/**/*'
# s.resource_bundles = {
# 'LQHelloWorld' => ['LQHelloWorld/Assets/*.png']
# }
# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
end
5,提交并验证Spec是否成功
- 1,$ pod lib lint --allow-warnings
此时如果为 LQHelloWorld passed validation. 则说明验证通过 - 2,$ git status
- 3,$ git add .
- 4,$ git commit -m '编辑spec文件'
- 5,$ git remote add origin https://gitee.com/lq326065285/LQHelloWorld.git (将本地库与远程代码仓库进行关联)
- 6,$ git push origin master (提交到远程仓库)
- 7,$ git tag '0.1.0' (要与LQHelloWorld.podspec文件中的tag值保持一致)
- 8,$ git push --tags(将tag提交到远程)
- 9,$ pod spec lint --allow-warnings
此时如果为 MyProjectBase passed validation. 则说明验证通过
步骤5可以先关联分支,再提交
- $ git branch --set-upstream-to origin/master master
- $ git push
6,添加本地索引库

pod repo push LQSpec LQHelloWorld.podspec
提交spec文件

这个时候我们也可以在本地查到,Spec文件

如果想重新增加一个版本,先通过
git tag 'x.x.x'
做好标记,提交到远程分之后,再修改LQHelloWorld.podspec
里面的版本号,重新提交即可
7,运行podSeach

这是由于缓存导致的问题,我们可以运行命令rm ~/Library/Caches/CocoaPods/search_index.json
删掉search_index.json文件。也可以手动删除search_index.json文件

重新运行 pod search

我还是有点不死心,那就再来个demo咯,Podfile文件如下

pod install

)
打开项目

perfect,至此,创建私有库的整个过程已经呈现在你面前了。
网友评论