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

相关推荐
奶糖的次元空间5 小时前
iOS 学习笔记 - SwiftUI 和 简单布局
ios·swift
zhensherlock10 小时前
Protocol Launcher 系列:App Store 精准引流与应用推广
javascript·macos·ios·typescript·iphone·mac·ipad
for_ever_love__13 小时前
Objective-C学习 NSDictionary,NSMutableDictionary 功能详解
开发语言·学习·ios·objective-c
for_ever_love__13 小时前
Objective-C学习 协议和委托
开发语言·学习·ios·objective-c
2501_915909061 天前
不用越狱就看不到 iOS App 内部文件?使用 Keymob 查看和导出应用数据目录
android·ios·小程序·https·uni-app·iphone·webview
@大迁世界1 天前
液态玻璃屏正在侵蚀你的电池
macos·ios·objective-c·cocoa
pop_xiaoli1 天前
【iOS】类与对象底层
macos·ios·objective-c·cocoa·xcode
sp42a1 天前
NativeScript iOS 平台开发技巧
ios·nativescript·app 开发
2501_915921431 天前
常用iOS性能测试工具大全及使用指南
android·测试工具·ios·小程序·uni-app·cocoa·iphone
for_ever_love__2 天前
Objecgtive-C学习实例对象,类对象, 元类对象与 isa指针
c语言·学习·ios