由于某些原因,当我尝试实例化一个额外的RCTBridge实例时,只启动了一个实例(首先创建的那个实例)。下面是我的AppDelegate中的代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Setup sync worker
self.syncThreadBridge = [[RCTBridge alloc] initWithDelegate:[SyncWorkerBridgeDelegate new] launchOptions:nil];
// React Native root view
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"Main_app"
initialProperties:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
// Return
return YES;
}使用此代码,仅启动同步线程桥,而不启动应用程序的主桥(但同步线程桥成功初始化并向Reactotron发送消息)。
如果我将同步线程桥初始化移到主应用程序桥初始化下面,那么主应用程序就会被初始化,呈现给用户,主应用程序会向Reactotron发送消息。但是,同步线程桥不会启动,也不会连接到Reactotron。
我的方法基于来自https://github.com/joltup/react-native-threads的代码-那里的示例代码似乎不能在我使用的React Native 0.63上工作。
那么,是否删除了创建多个JS运行时的选项?
发布于 2021-01-24 23:25:33
实际上,我刚刚在一个全新的React Native 0.63.4应用程序上尝试了一下,它是有效的:https://github.com/backmeupplz/react-native-ios-threading-example
https://stackoverflow.com/questions/65866799
复制相似问题