iOS搭建组件化私有库

一、创建私有库索引

在码云建立一个私有库索引,起名为TKComponentSpec

image.png

二、本地添加私有库索引

  • 添加私有库索引
pod repo add TKComponentSpec https://gitee.com/libtinker/tkcomponent-spec.git
  • 查看本地私有库索引


    image.png

三、创建功能组件库

当你新建自建的时候,就从这里开始

  • 在码云上创建组件库,命名为TKKit,如下图:
    image.png
  • 创建TKKit本地库
pod lib create TKKit
  • 在私有库中导入自己的代码
    class文件下面导入自己的代码文件,并删除ReplaceMe.m文件
    image.png
  • 更新整个工程的pod库
    1.cd到Example文件下
    2.执行 pod install
  • 修改.podspec文件
    image.png

    image.png

    有两个属性需要修改:
    s.homepage:私有库地址
    s.source:私有库源码地址
  • 将私有库push到远程仓库
    cd 到私有库
git branch master
git checkout master
git status (检查当前的git存了什么文件)
git add . (将所有文件缓存到待提交文件区域)
git commit -m "上传组件"
git remote add origin https://gitee.com/libtinker/tkkit.git (私有库索引)
git push -f origin master (提交代码到远程仓库master分支上)
git tag 0.0.1 (这里的版本号必须和podspec里面的一致)
git push --tag (提交tag)
  • 本地和远程校验
    1.本地私有库校验:
pod lib lint --private --allow-warnings

校验成功:TKKIt passed validation
2.远程私有库验证:

pod spec lint --private --allow-warnings

校验成功:TKKIt.pidspec passed validation

  • 提交索引文件到远程索引库
    1.检查没问题后,提交索引文件到远程索引库
私有库
pod repo push TKComponentSpec TKKit.podspec  --allow-warnings
公有库
pod trunk push TKStackCard.podspec --allow-warnings 

2.推送之后到本地索引库中查看


image.png

3.在远端getee上查看


image.png

四、私有库使用

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

source 'https://gitee.com/libtinker/tkcomponent-spec.git'

target 'TestDemo' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  pod 'TKKit'

end

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容