ios CI/CD 持续集成 组件化专题三 IOS打包Bundle与加载Bundle中的图片

一、 读取 BundlePath

  • (NSString *)sdkPodsBundlePath {

NSBundle *bundle = [NSBundle bundleForClass:[self class]];

NSString *bundlePath = [bundle pathForResource:kSDKName ofType:@"bundle"];

return bundlePath;

}

二 、读取bundle

  • (NSBundle *)sdkBundle {

NSString *sdkPodsBundlePath = [QSGetResourceTool sdkPodsBundlePath];

NSBundle *bd = nil;

// SDK 自己使用时

if (sdkPodsBundlePath) {

NSBundle *bundle = [NSBundle bundleForClass:[self class]];

NSString *bundlePath = [bundle pathForResource:kSDKName ofType:@"bundle"];

NSBundle *bd = [NSBundle bundleWithPath:bundlePath];

} else {

bd = [NSBundle bundleForClass:[self class]];

}

return bd;

}

三、 读取bundle里面的图片

// 读取framework下的图片资源

  • (UIImage *)qs_imageSDKNamed:(NSString *)name {

NSBundle *bd = [QSGetResourceTool sdkBundle];

UIImage *image = [UIImage imageNamed:name inBundle:bd compatibleWithTraitCollection:nil];

return image;

}

四、 使用

UIImage * image = [UIImage qs_imageSDKNamed:@"xxx"];

相关推荐
Zender Han5 小时前
Flutter 新版 Google Sign-In 插件完整解析(含示例讲解)
android·flutter·ios·web
Digitally6 小时前
如何在iPhone上共享日历
ios·iphone
库奇噜啦呼8 小时前
【iOS】多线程学习
macos·ios·cocoa
xiAo_Ju10 小时前
iOS一个Fancy UI的Tricky实现
前端·ios
游戏开发爱好者810 小时前
iOS 商店上架全流程解析 从工程准备到审核通过的系统化实践指南
android·macos·ios·小程序·uni-app·cocoa·iphone
QuantumLeap丶13 小时前
《Flutter全栈开发实战指南:从零到高级》- 18 -自定义绘制与画布
android·flutter·ios
玲珑Felone18 小时前
flutter 状态管理--InheritedWidget、Provider原理解析
android·flutter·ios
AskHarries20 小时前
中国身份证注册美区 Apple Developer 个人账号完整教程
ios·apple
2501_916008891 天前
Objective-C 测试(OC 测试)指南 从单元测试到性能调优的多工具协同方法
android·ios·小程序·https·uni-app·iphone·webview