CocoaPods 私有库创建

总结流程和pod 指令,以及自己操作遇到的问题。

参考文章

iOS组件化 - 基础
iOS组件化 - 项目组件化

Swift/Objective-C-使用Cocoapods创建/管理私有库(初中级用法)
Swift/Objective-C-使用Cocoapods创建/管理私有库(高级用法)

文章目录

        • 参考文章
      • 创建自己的私有库
          • 1、创建私有Spec Repo
          • 2、创建组件库
          • 3、提交组件库
            • 3.1 验证本地库
            • 3.2 提交到git
            • 3.3 将库文件推送到远端私有库
          • 4、使用私有库
          • 5、总结
          • 6、在码云创建私有库
        • 参考文章
        • 问题记录
          • 1、include of non-modular header inside framework module

创建自己的私有库

1、创建私有Spec Repo

1.1 在 GitHub 上创建一个仓库作为私有库;
1.2 在本地创建私有库

命令
	pod repo add [私有仓库名称] [GitHub HTTPS 链接地址]
例:
	pod repo add DYDemoSpecs https://github.com/liyunxin/DYDemoSpecs.git
2、创建组件库

2.1 在本地创建组件库
在命令行 cd 进入想要把组件库存入的文件夹,执行下面命令:

命令
	pod lib create [库名称]
例
	pod lib create DYDemoTest

根据提示填入数据

What platform do you want to use?? [ iOS / macOS ]
 > iOS

What language do you want to use?? [ Swift / ObjC ]
 > ObjC

Would you like to include a demo application with your library? [ Yes / No ]
 > Yes

Which testing frameworks will you use? [ Specta / Kiwi / None ]
 > None

Would you like to do view based testing? [ Yes / No ]
 > No

What is your class prefix?
 > DY

2.2 在 git 上创建组件库,并且把本地组件库和远端关联
2.3 添加类文件和资源文件到库中
库的列表如下

DYDemoTest
- ...
- DYDemoTest
	- Assets
	- Classes
- DYDemoTest.podspec
- Example
- ...

新建的类文件存入 Classes 文件夹中,或者自行新建文件夹,存入新建的文件夹。同时修改 DYDemoTest.podspec 中对应的地址。

s.source_files = 'DYDemoTest/Classes/**/*'

例如文件存入Base文件夹

s.subspec 'Base' do |sb|
	# 类文件路径
    sb.source_files = 'DYDemoTest/Base/**/*.{h,m}'
    # 资源文件路径
    sb.resource_bundles = {
      'DYDemoTest' => ['DYDemoTest/Base/*.xcassets']
    }
  end
 
 

你可能感兴趣的:(iOS,私有仓库)