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

相关推荐
linweidong20 小时前
实战救火型 从 500MB 降到 50MB:高频业务场景下的 iOS 内存急救与避坑指南
macos·ios·objective-c·cocoa·ios面试·nstimer·ios面经
山里看瓜1 天前
解决 iOS 上 Swiper 滑动图片闪烁问题:原因分析与最有效的修复方式
前端·css·ios
网络研究院1 天前
苹果修复了iOS系统中两个被定向攻击利用的零日漏洞
macos·ios·cocoa
如此风景1 天前
IOS SwiftUI 全组件详解
ios
雾散声声慢1 天前
解决 iOS 上 Swiper 滑动图片闪烁问题:原因分析与最有效的修复方式
前端·css·ios
QuantumLeap丶1 天前
《Flutter全栈开发实战指南:从零到高级》- 24 -集成推送通知
android·flutter·ios
YungFan1 天前
iOS开发之MetricKit监控App性能
ios·swiftui·swift
二流小码农1 天前
鸿蒙开发:上架困难?谈谈我的上架之路
android·ios·harmonyos
图图大恼1 天前
在iOS上体验Open-AutoGLM:从安装到流畅操作的完整指南
人工智能·ios·agent
笑尘pyrotechnic1 天前
[iOS原理] Block的本质
ios·objective-c·cocoa