ios原生无法调用framework内部使用RN打包的bundle文件(RN版本为0.59.0)



  • 将RN打包成bundle文件。放在framework中。
    原生ios集成framework后,调用不到bundle文件内容。
    下图是framework中的bundle文件引用方式。可以正常预览bundle文件内容。代码如下:

    #import "ShowResultViewController.h"
    #import <React/RCTRootView.h>
    @interface ShowResultViewController ()
    @property (nonatomic, strong) NSMutableArray* labels;@end
    @implementation ShowResultViewController

    • (void)viewDidLoad {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
      // 设置该view的背景色
      self.view.backgroundColor = [UIColor redColor];

      NSURL * jsCodeLocation= [[NSBundle mainBundle] URLForResource:@"index.ios" withExtension:@"bundle"];

      RCTRootView * rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
      moduleName:@"test59"
      initialProperties:nil
      launchOptions:nil];
      self.view = rootView;

    }

    #import "ViewController.h"
    #import <React/RCTRootView.h>
    @interface ViewController ()

    @end

    @implementation ViewController

    • (void)viewDidLoad {
      [super viewDidLoad];
      ShowResultViewController *zxd=[[ShowResultViewController alloc] init];
      [self.view addSubview:zxd.view];

    }


Log in to reply