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

相关推荐
MaoJiu1 小时前
Flutter混合开发:在iOS工程中嵌入Flutter Module
flutter·ios
2501_915921433 小时前
小团队如何高效完成 uni-app iOS 上架,从分工到工具组合的实战经验
android·ios·小程序·uni-app·cocoa·iphone·webview
2501_916008894 小时前
uni-app iOS 文件管理与 itools 配合实战,多工具协作的完整流程
android·ios·小程序·https·uni-app·iphone·webview
Digitally5 小时前
如何将视频从 iPhone 转移到 Mac
macos·ios·iphone
2501_916007476 小时前
uni-app iOS 文件调试常见问题与解决方案:结合 itools、克魔、iMazing 的实战经验
android·ios·小程序·https·uni-app·iphone·webview
豆豆(设计前端)6 小时前
使用 Uni-app 打包 外链地址APK 及 iOS 注意事项
ios·uni-app
库奇噜啦呼9 小时前
属性关键字
ios
2501_9159184113 小时前
uni-app 项目 iOS 上架踩坑经验总结 从证书到审核的避坑指南
android·ios·小程序·https·uni-app·iphone·webview
游戏开发爱好者813 小时前
iOS 上架 uni-app 流程全解析,从打包到发布的完整实践
android·ios·小程序·https·uni-app·iphone·webview
他们都不看好你,偏偏你最不争气21 小时前
AutoLayout与Masonry:简化iOS布局
ios