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

相关推荐
小鹿软件办公2 小时前
苹果因通信问题撤回面向旧款 iPhone 和 iPad 的系统更新
ios·iphone
Thomas_YXQ12 小时前
Unity3D在ios平台下内存的优化详解
开发语言·macos·ios·性能优化·cocoa
zhyongrui19 小时前
SwiftUI 光晕动画性能优化:消除托盘缩放卡顿的实战方案
ios·性能优化·swiftui
TheNextByte119 小时前
如何通过 6 种方式删除 iPhone/iPad 上的文件
ios·iphone·ipad
WeiAreYoung21 小时前
uni-app Xcode制作iOS谷歌广告Google Mobile Ads SDK插件
ios·uni-app
2501_916008891 天前
iOS 开发助手工具,设备信息查看、运行日志、文件管理等方面
android·ios·小程序·https·uni-app·iphone·webview
编程之路从0到11 天前
React Native新架构之iOS端初始化源码分析
react native·ios·源码剖析·新架构·初始化流程
2501_915921431 天前
在没有源码的前提下,怎么对 Swift 做混淆,IPA 混淆
android·开发语言·ios·小程序·uni-app·iphone·swift
00后程序员张2 天前
对比 Ipa Guard 与 Swift Shield 在 iOS 应用安全处理中的使用差异
android·开发语言·ios·小程序·uni-app·iphone·swift
00后程序员张2 天前
在 iOS 设备上同时监控 CPU、GPU 与内存的方法
android·ios·小程序·https·uni-app·iphone·webview