Search code examples
react-nativeyarn-workspacesmetro-bundler

How can i solve: "RCTBridge required dispatch_sync to load" in React Native using yarn workspaces?


i follow the medium article: React Native 0.63 Monorepo walkthrough carefully to get yarn workspaces works with react-native. Everhtings works, i can build my iOS und Android App and also the Metro Bundler works, but i get the following warning from the metro bundler when i build my iOS App with yarn workspace mobile ios

RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks

I don't get this warning unless I use react-native with yarn workspaces. Therefore, I suspect that the error is generated by my monorepo setup.

Do you have any idea how I can remove this warning?


Solution

  • Open Your /ios/YourAppName/AppDelegate.m

    #import "AppDelegate.h"
    
    // ADD THIS
    #if RCT_DEV
    #import <React/RCTDevLoadingView.h>
    #endif
    // TILL HERE
    
    #import <React/RCTBridge.h>
    #import <React/RCTBundleURLProvider.h>
    #import <React/RCTRootView.h>
    ...
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    
    ...
      RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation
                                                moduleProvider:nil
                                                 launchOptions:launchOptions];
    // THIS CONDITION
    #if RCT_DEV
      [bridge moduleForClass:[RCTDevLoadingView class]];
    #endif
      RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                       moduleName:@"Test"
                                                initialProperties:nil];
    // TILL HERE
      ...
    }
    

    source here