Wednesday, September 30, 2026
HomeiOS Developmentios - Enabling TurboModule and Material in React Native 0.68 results in...

ios – Enabling TurboModule and Material in React Native 0.68 results in lot of error

[ad_1]

I’m utilizing React Native 0.68 and making an attempt to make use of TurboModules and Material

That is my AppDelegate.mm file

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <React/RCTAppSetupUtils.h>

#if RCT_NEW_ARCH_ENABLED
#import <React/RCTDataRequestHandler.h>
#import <React/RCTHTTPRequestHandler.h>
#import <React/RCTFileRequestHandler.h>
#import <React/RCTNetworking.h>
#import <React/RCTImageLoader.h>
#import <React/RCTGIFImageDecoder.h>
#import <React/RCTLocalAssetImageLoader.h>

#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>

#import <react/config/ReactNativeConfig.h>

@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
  RCTTurboModuleManager *_turboModuleManager;
  RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
  std::shared_ptr<const fb::react::ReactNativeConfig> _reactNativeConfig;
  fb::react::ContextContainer::Shared _contextContainer;
}
@finish
#endif

@implementation AppDelegate

- (BOOL)software:(UIApplication *)software didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  RCTAppSetupPrepareApp(software);
  // RCTEnableTurboModule(YES);
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];

#if RCT_NEW_ARCH_ENABLED
  _contextContainer = std::make_shared<fb::react::ContextContainer const>();
  _reactNativeConfig = std::make_shared<fb::react::EmptyReactNativeConfig const>();
  _contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
  _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
  bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif

  UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"DummyProject2", nil);

  if (@out there(iOS 13.0, *)) {
    rootView.backgroundColor = [UIColor systemBackgroundColor];
  } else {
    rootView.backgroundColor = [UIColor whiteColor];
  }

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"most important" withExtension:@"jsbundle"];
#endif
}

#if RCT_NEW_ARCH_ENABLED

#pragma mark - RCTCxxBridgeDelegate

- (std::unique_ptr<fb::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
  if (RCTTurboModuleEnabled()) {
    _turboModuleManager =
        [[RCTTurboModuleManager alloc] initWithBridge:bridge
                                             delegate:self
                                            jsInvoker:bridge.jsCallInvoker];

    // Needed to permit NativeModules to lookup TurboModules
    [bridge setRCTTurboModuleRegistry:_turboModuleManager];

    if (!RCTTurboModuleEagerInitEnabled()) {
      /**
       * Instantiating DevMenu has the side-effect of registering
       * shortcuts for CMD + d, CMD + i,  and CMD + n through RCTDevMenu.
       * Due to this fact, when TurboModules are enabled, we should manually create this
       * NativeModule.
       */
       [_turboModuleManager moduleForName:"DevMenu"];
    }
  }

  // Add this line...
  __weak __typeof(self) weakSelf = self;

  // If you wish to use the `JSCExecutorFactory`, bear in mind so as to add the `#import <React/JSCExecutorFactory.h>`
  // import assertion on high.
  return std::make_unique<fb::react::HermesExecutorFactory>(
    fb::react::RCTJSIExecutorRuntimeInstaller([weakSelf, bridge](fb::jsi::Runtime &runtime) {
      if (!bridge) {
        return;
      }

      // And add these traces to put in the bindings...
      __typeof(self) strongSelf = weakSelf;
      if (strongSelf) {
        fb::react::RuntimeExecutor syncRuntimeExecutor =
            [&](std::perform<void(fb::jsi::Runtime & runtime_)> &&callback) { callback(runtime); };
        [strongSelf->_turboModuleManager installJSBindingWithRuntimeExecutor:syncRuntimeExecutor];
      }
    }));
}

#pragma mark RCTTurboModuleManagerDelegate

- (Class)getModuleClassFromName:(const char *)identify
{
  return RCTCoreModulesClassProvider(identify);
}

- (std::shared_ptr<fb::react::TurboModule>)getTurboModule:(const std::string &)identify
                                                      jsInvoker:(std::shared_ptr<fb::react::CallInvoker>)jsInvoker
{
  return nullptr;
}

- (std::shared_ptr<fb::react::TurboModule>)getTurboModule:(const std::string &)identify
                                                     initParams:
                                                         (const fb::react::ObjCTurboModule::InitParams &)params
{
  return nullptr;
}

- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
{
  // Arrange the default RCTImageLoader and RCTNetworking modules.
  if (moduleClass == RCTImageLoader.class) {
    return [[moduleClass alloc] initWithRedirectDelegate:nil
        loadersProvider:^NSArray<id<RCTImageURLLoader>> *(RCTModuleRegistry * moduleRegistry) {
          return @ [[RCTLocalAssetImageLoader new]];
        }
        decodersProvider:^NSArray<id<RCTImageDataDecoder>> *(RCTModuleRegistry * moduleRegistry) {
          return @ [[RCTGIFImageDecoder new]];
        }];
  } else if (moduleClass == RCTNetworking.class) {
     return [[moduleClass alloc]
        initWithHandlersProvider:^NSArray<id<RCTURLRequestHandler>> *(
            RCTModuleRegistry *moduleRegistry) {
          return @[
            [RCTHTTPRequestHandler new],
            [RCTDataRequestHandler new],
            [RCTFileRequestHandler new],
          ];
        }];
  }
  // No customized initializer right here.
  return [moduleClass new];
}

#endif

@finish

When I attempt to run my mission with out enabling TurboModules and Material, it really works superb for the primary time

If I uncomment RCTEnableTurboModule(YES); within the above code I get an error saying

Unable to seek out module for RedBox

If I once more remark RCTEnableTurboModule(YES); and attempt to simply use Material, I get an error saying No member named ‘’RCTJSIExecutorRuntimeInstaller’ in namespace ‘fb::react’ Test this https://firebasestorage.googleapis.com/v0/b/artable-5da4b.appspot.com/o/Fabricpercent20Error.png?alt=media&token=9a3a3ce2-3e77-4236-bad8-bf9535ba1bdc for extra particulars

For Material I did replace my podfile to make use of Material. I did replace babel.config.js as properly

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    '@babel/plugin-proposal-class-properties',
    './node_modules/react-native/packages/babel-plugin-codegen',
  ],
};

and ran

USE_FABRIC=1 RCT_NEW_ARCH_ENABLED=1 pod set up

Then I attempt to remark cloth as properly together with TurboModules and reverted babel.config.js to unique code. Did pod set up and npm I as properly however I get an error saying

React/renderer/parts/view/ViewEventEmitter.h file not discovered

Test this https://firebasestorage.googleapis.com/v0/b/artable-5da4b.appspot.com/o/Screenshotpercent202022-04-09percent20atpercent206.29.17percent20PM.png?alt=media&token=d76ace74-cf62-48a0-8663-4777ad0f505b

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments