当前位置: 移动技术网 > IT编程>移动开发>IOS > iOS组件化开发-发布私有库

iOS组件化开发-发布私有库

2020年03月09日  | 移动技术网IT编程  | 我要评论

天下第二如水一方,纱巾角枕病眠翁,十八岁的约定演员表

远程索引库

将远程索引库添关联到本地

pod repo 查看本地已关联仓库源
pod repo add  本地索引库名称 远程索引库仓库地址
pod repo update 索引库名称
pod repo remove 本地索引库名称

 执行命令 添加远程索引库`ktpodspecs`克隆到本地

远程库 

新建框架工程ktuikit

利用模板自动生成私有库工程 

pod lib create 框架名称
pod lib create ktuikit

生成的工程依赖关系

ktuikit的示例工程的podfile配置spec的路径是相对于本地podfile的路径

编写podspec 

依赖第三方库

framewirks:依赖系统的动态库 比如 uikit
vendored_framework:依赖非系统的动态库 比如tencentopenapi.framework
libraries:依赖系统静态库 比如libstdc++.a
vendored_libraries:依赖非系统的静态库 比如新浪微博的libweibosdk.a
dependency:依赖pod库

上传框架到远程仓库 

 新建远程仓库

进入本地ktuikit目录执行git命令 与远程ktuikit建立关联

git remote add origin https://github.com/coderketao/ktuikit.git
git branch --set-upstream-to=origin/master master 本地分支远程分支建立track

 

建立关联后,本地ktuikit push到远程仓库 注意:push过程记得一定将pods和podfile.lock文件忽略,否则导致pod install和pod repo push很慢

远程master分支添加tag 执行命令

git tag '0.1.0' 添加
git push --tags
git tag -d 0.1.0 删除
git push origin :0.1.0

私有库发布

将podspec文件到远程索引库 执行命令 验证`ktuikit.podspec`是否合法

pod lib lint ktuikit.podspec --allow-warnings --use-libraries 验证本地

执行命令 发布podspec到远程索引仓库

pod repo push ktpodspecs ktuikit.podspec --allow-warnings --use-libraries 

在构建组件时,如果该组件引用了其它库

s.dependendy 'sdwebimage'
s.dependendy 'afnetworking'

在验证、推送远程索引库加上pod的source

复制代码
pod lib lint ktuikit.podspec --sources='http://47.93.191.194:9002/hongketao/qxcomponentspecs.git,https://github.com/cocoapods/specs.git' --allow-warnings --use-libraries 

pod repo push ktpodspecs ktuikit.podspec --sources='http://47.93.191.194:9002/hongketao/qxcomponentspecs.git,https://github.com/cocoapods/specs.git' --allow-warnings --use-libraries 
复制代码

 

私有库使用

新建项目,应用私有库 

 podspec的写法

~> 1.2.0 要求版本 [1.2.0, 2.0.0)
<= 1.2.0 版本小于等于1.2.0 超过后1.2.0后不再更新

指定三方库本地路径的写法(用于提交前进行测试)

pod 'afnetworking', :path => '~/desktop/afnetworking'

指定git的写法

pod 'afnetworking', :git => 'https://github.com/afnetworking/afnetworking.git'

pod 'afnetworking', :git => 'https://github.com/afnetworking/afnetworking.git', :branch => 'dev'

pod 'afnetworking', :git => 'https://github.com/afnetworking/afnetworking.git', :tag => '3.1.1'

pod 'afnetworking', :git => 'https://github.com/afnetworking/afnetworking.git', :commit => '0f506b1c45'

指定podspec的写法

pod 'afnetworking', :podspec => '~/desktop/afnetworking/afnetworking.podspec'

指定subspecs的写法(这也是subspec的另一个用法

pod 'mythirdparty', '~> 0.0.1', :subspecs => ['sparta', 'gotyesdk', 'talkingdata', 'tingyun', 'baidupanorama']

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网