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"];

相关推荐
HarderCoder4 小时前
Swift 中的基本运算符:从加减乘除到逻辑与或非
ios·swift
HarderCoder5 小时前
Swift 中“特性开关”实战笔记——用编译条件+EnvironmentValues优雅管理Debug/TestFlight/AppStore三环境
ios·swift
HarderCoder5 小时前
Swift 并发任务中到底该不该用 `[weak self]`?—— 从原理到实战一次讲透
ios·swift
FeliksLv6 小时前
iOS 集成mars xlog
ios
2501_915106327 小时前
CDN 可以实现 HTTPS 吗?实战要点、部署模式与真机验证流程
网络协议·http·ios·小程序·https·uni-app·iphone
大熊猫侯佩1 天前
在肖申克监狱玩转 iOS 26:安迪的 Liquid Glass 复仇计划
ios·swiftui·swift
非专业程序员2 天前
逆向分析CoreText中的字体级联/Font Fallback机制
前端·ios
库奇噜啦呼2 天前
【iOS】简单的四则运算
macos·ios·cocoa
white-persist2 天前
【burp手机真机抓包】Burp Suite 在真机(Android and IOS)抓包手机APP + 微信小程序详细教程
android·前端·ios·智能手机·微信小程序·小程序·原型模式
恋猫de小郭3 天前
Fluttercon EU 2025 :Let‘s go far with Flutter
android·开发语言·flutter·ios·golang