创建SDK项目
pod lib create <sdk name>

需要回答几个问题
- 使用什么平台?
- 使用什么语言?
- 是否需要demo项目?
- 使用什么测试框架?
- 是否需要集成基于view的测试框架?
-
使用什么文件名前缀?
截屏2020-12-30 下午4.23.33.png
sdk生成成功后会自动使用Xcode打开项目

包含demo的sdk项目

podspec文件包含sdk项目的所有配置信息

如果sdk中包含资源文件,需要从sdk的bundle中加载
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"Frameworks/TFExampleLib.framework/TFExampleLib.bundle" ofType:nil];
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.bounds];
imageView.image = [UIImage imageNamed:@"moon" inBundle:bundle compatibleWithTraitCollection:nil];

打包成framework
pod package <sdk name>.podspec

生成framework成功


Xcode12在模拟器和真机编译的Framework都有包含arm64的架构,所以使用pod package直接打包Framework会报错,具体解决方案可以参考:
IOS pod package 报错:Pods/build/package.a and Pods/build-sim/package.a have the same architectures
网友评论