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

// 在混编项目中会出现 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;
}

你可能感兴趣的:(关于 Pod 库的资源bundle 获取的问题)