11#import " AppDelegate.h"
22
3- #import < React/RCTBridge.h>
43#import < React/RCTBundleURLProvider.h>
5- #import < React/RCTRootView.h>
6- #import < React/RCTAppSetupUtils.h>
74#import " RNSplashScreen.h"
85
9- #if RCT_NEW_ARCH_ENABLED
10- #import < React/CoreModulesPlugins.h>
11- #import < React/RCTCxxBridgeDelegate.h>
12- #import < React/RCTFabricSurfaceHostingProxyRootView.h>
13- #import < React/RCTSurfacePresenter.h>
14- #import < React/RCTSurfacePresenterBridgeAdapter.h>
15- #import < ReactCommon/RCTTurboModuleManager.h>
16- #import < react/config/ReactNativeConfig.h>
17-
18- static NSString *const kRNConcurrentRoot = @" concurrentRoot" ;
19-
20- @interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
21- RCTTurboModuleManager *_turboModuleManager;
22- RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
23- std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
24- facebook::react::ContextContainer::Shared _contextContainer;
25- }
26- @end
27- #endif
28-
296@implementation AppDelegate
307
8+
319- (BOOL )application : (UIApplication *)application didFinishLaunchingWithOptions : (NSDictionary *)launchOptions
3210{
33- RCTAppSetupPrepareApp (application);
34-
35- RCTBridge *bridge = [[RCTBridge alloc ] initWithDelegate: self launchOptions: launchOptions];
36-
37- #if RCT_NEW_ARCH_ENABLED
38- _contextContainer = std::make_shared<facebook::react::ContextContainer const >();
39- _reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const >();
40- _contextContainer->insert (" ReactNativeConfig" , _reactNativeConfig);
41- _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc ] initWithBridge: bridge contextContainer: _contextContainer];
42- bridge.surfacePresenter = _bridgeAdapter.surfacePresenter ;
43- #endif
44-
45- NSDictionary *initProps = [self prepareInitialProps ];
46- UIView *rootView = RCTAppSetupDefaultRootView (bridge, @" RNTypescriptBoilerplate" , initProps);
47-
48- if (@available (iOS 13.0 , *)) {
49- rootView.backgroundColor = [UIColor systemBackgroundColor ];
50- } else {
51- rootView.backgroundColor = [UIColor whiteColor ];
52- }
11+ self.moduleName = @" RNTypescriptBoilerplate" ;
12+ // You can add your custom initial props in the dictionary below.
13+ // They will be passed down to the ViewController used by React Native.
14+ self.initialProps = @{};
5315
54- // SplashScreen Initialization
55- [RNSplashScreen show ];
16+ bool didFinish=[super application: application didFinishLaunchingWithOptions: launchOptions];
5617
57- self.window = [[UIWindow alloc ] initWithFrame: [UIScreen mainScreen ].bounds];
58- UIViewController *rootViewController = [UIViewController new ];
59- rootViewController.view = rootView;
60- self.window .rootViewController = rootViewController;
61- [self .window makeKeyAndVisible ];
62- return YES ;
63- }
64-
65- // / This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
66- // /
67- // / @see: https://reactjs.org/blog/2022/03/29/react-v18.html
68- // / @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
69- // / @return: `true` if the `concurrentRoot` feture is enabled. Otherwise, it returns `false`.
70- - (BOOL )concurrentRootEnabled
71- {
72- // Switch this bool to turn on and off the concurrent root
73- return true ;
74- }
75- - (NSDictionary *)prepareInitialProps
76- {
77- NSMutableDictionary *initProps = [NSMutableDictionary new ];
78- #ifdef RCT_NEW_ARCH_ENABLED
79- initProps[kRNConcurrentRoot ] = @([self concurrentRootEnabled ]);
80- #endif
81- return initProps;
18+ [RNSplashScreen show ]; // here
19+ return didFinish;
8220}
8321
8422- (NSURL *)sourceURLForBridge : (RCTBridge *)bridge
@@ -90,43 +28,14 @@ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
9028#endif
9129}
9230
93- #if RCT_NEW_ARCH_ENABLED
94-
95- #pragma mark - RCTCxxBridgeDelegate
96-
97- - (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge : (RCTBridge *)bridge
98- {
99- _turboModuleManager = [[RCTTurboModuleManager alloc ] initWithBridge: bridge
100- delegate: self
101- jsInvoker: bridge.jsCallInvoker];
102- return RCTAppSetupDefaultJsExecutorFactory (bridge, _turboModuleManager);
103- }
104-
105- #pragma mark RCTTurboModuleManagerDelegate
106-
107- - (Class )getModuleClassFromName : (const char *)name
108- {
109- return RCTCoreModulesClassProvider (name);
110- }
111-
112- - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule : (const std::string &)name
113- jsInvoker : (std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
114- {
115- return nullptr ;
116- }
117-
118- - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule : (const std::string &)name
119- initParams :
120- (const facebook::react::ObjCTurboModule::InitParams &)params
121- {
122- return nullptr ;
123- }
124-
125- - (id <RCTTurboModule>)getModuleInstanceFromClass : (Class )moduleClass
31+ // / This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
32+ // /
33+ // / @see: https://reactjs.org/blog/2022/03/29/react-v18.html
34+ // / @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
35+ // / @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
36+ - (BOOL )concurrentRootEnabled
12637{
127- return RCTAppSetupDefaultModuleFromClass (moduleClass) ;
38+ return true ;
12839}
12940
130- #endif
131-
13241@end
0 commit comments