Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 9 additions & 44 deletions lib/ios/RNNAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import "RNNAppDelegate.h"
#import <ReactNativeNavigation/ReactNativeNavigation.h>

#ifdef RCT_NEW_ARCH_ENABLED

#import "RCTAppSetupUtils.h"
#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
Expand All @@ -23,11 +23,9 @@

static NSString *const kRNConcurrentRoot = @"concurrentRoot";

@interface RNNAppDelegate () <RCTTurboModuleManagerDelegate, RCTCxxBridgeDelegate> {}
@interface RNNAppDelegate () <RCTTurboModuleManagerDelegate> {}
@end

#endif

@implementation RNNAppDelegate

- (BOOL)application:(UIApplication *)application
Expand All @@ -36,26 +34,16 @@ - (BOOL)application:(UIApplication *)application
// Copied from RCTAppDelegate, it private inside it
self.rootViewFactory = [self createRCTRootViewFactory];

#ifdef RCT_NEW_ARCH_ENABLED
RCTAppSetupPrepareApp(application, self.turboModuleEnabled);
RCTAppSetupPrepareApp(application, self.newArchEnabled);
RCTSetNewArchEnabled(TRUE);
RCTEnableTurboModuleInterop(YES);
RCTEnableTurboModuleInteropBridgeProxy(YES);

self.rootViewFactory.reactHost = [self.rootViewFactory createReactHost:launchOptions];

if (self.bridgelessEnabled) {
// Creating host instead of bridge
self.rootViewFactory.reactHost = [self.rootViewFactory createReactHost:launchOptions];

[ReactNativeNavigation bootstrapWithHost:self.rootViewFactory.reactHost];

return YES;
}
#endif
// Force RN to init all necessary modules instead of copy-pasting code (ex. bridge)
[self.rootViewFactory viewWithModuleName:@""];
[ReactNativeNavigation bootstrapWithHost:self.rootViewFactory.reactHost];

[ReactNativeNavigation bootstrapWithBridge:self.bridge];

return YES;
return YES;
}

- (RCTRootViewFactory *)createRCTRootViewFactory
Expand All @@ -68,31 +56,9 @@ - (RCTRootViewFactory *)createRCTRootViewFactory

RCTRootViewFactoryConfiguration *configuration =
[[RCTRootViewFactoryConfiguration alloc] initWithBundleURLBlock:bundleUrlBlock
newArchEnabled:self.fabricEnabled
turboModuleEnabled:self.turboModuleEnabled
bridgelessEnabled:self.bridgelessEnabled];

if (!self.bridgelessEnabled) {
configuration.extraModulesForBridge = ^NSArray<id<RCTBridgeModule>> * _Nonnull(RCTBridge * _Nonnull bridge) {
return [ReactNativeNavigation extraModulesForBridge:bridge];
};
}

configuration.createRootViewWithBridge = ^UIView *(RCTBridge *bridge, NSString *moduleName, NSDictionary *initProps)
{
// Ignoring creation of default view, will initialize our custom UIViewController later
return nil;
};
newArchEnabled:self.newArchEnabled];

configuration.createBridgeWithDelegate = ^RCTBridge *(id<RCTBridgeDelegate> delegate, NSDictionary *launchOptions)
{
return [weakSelf createBridgeWithDelegate:delegate launchOptions:launchOptions];
};

#ifndef RCT_NEW_ARCH_ENABLED
return [[RCTRootViewFactory alloc] initWithConfiguration:configuration];
}
#else
return [[RCTRootViewFactory alloc] initWithConfiguration:configuration andTurboModuleManagerDelegate:self];
}

Expand All @@ -117,7 +83,6 @@ - (Class)getModuleClassFromName:(const char *)name {
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass {
return RCTAppSetupDefaultModuleFromClass(moduleClass, self.dependencyProvider);
}
#endif

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
[NSException raise:@"RCTBridgeDelegate::sourceURLForBridge not implemented"
Expand Down
Loading