关于 Pod 库的资源bundle 获取的问题

2019-07-24  本文已影响0人  iPhone
// 在混编项目中会出现 bundle 为nil 导致的崩溃问题,解决如下
/**
 * 获取bundle
 */
- (NSBundle *)getResourceBundle {
    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
    NSURL *bundleURL = [bundle URLForResource:@"YTBridgeModule" withExtension:@"bundle"];
    NSBundle *resourceBundle = [NSBundle bundleWithURL:bundleURL];
    if (!resourceBundle) {
        NSString * bundlePath = [bundle.resourcePath stringByAppendingPathComponent:@"YTBridgeModule.bundle"];
        resourceBundle = [NSBundle bundleWithPath:bundlePath];
    }
    return resourceBundle ?: bundle;
}
上一篇下一篇

猜你喜欢

热点阅读