@@ -4,18 +4,36 @@ import React_RCTAppDelegate
4
4
import ReactAppDependencyProvider
5
5
6
6
@main
7
- class AppDelegate : RCTAppDelegate {
8
- override func application( _ application: UIApplication , didFinishLaunchingWithOptions launchOptions: [ UIApplication . LaunchOptionsKey : Any ] ? = nil ) -> Bool {
9
- self . moduleName = " HelloWorld "
10
- self . dependencyProvider = RCTAppDependencyProvider ( )
7
+ class AppDelegate : UIResponder , UIApplicationDelegate {
8
+ var window : UIWindow ?
11
9
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 = [ : ]
10
+ var reactNativeDelegate : ReactNativeDelegate ?
11
+ var reactNativeFactory : RCTReactNativeFactory ?
15
12
16
- return super. application ( application, didFinishLaunchingWithOptions: launchOptions)
13
+ func application(
14
+ _ application: UIApplication ,
15
+ didFinishLaunchingWithOptions launchOptions: [ UIApplication . LaunchOptionsKey : Any ] ? = nil
16
+ ) -> Bool {
17
+ let delegate = ReactNativeDelegate ( )
18
+ let factory = RCTReactNativeFactory ( delegate: delegate)
19
+ delegate. dependencyProvider = RCTAppDependencyProvider ( )
20
+
21
+ reactNativeDelegate = delegate
22
+ reactNativeFactory = factory
23
+
24
+ window = UIWindow ( frame: UIScreen . main. bounds)
25
+
26
+ factory. startReactNative (
27
+ withModuleName: " HelloWorld " ,
28
+ in: window,
29
+ launchOptions: launchOptions
30
+ )
31
+
32
+ return true
17
33
}
34
+ }
18
35
36
+ class ReactNativeDelegate : RCTDefaultReactNativeFactoryDelegate {
19
37
override func sourceURL( for bridge: RCTBridge ) -> URL ? {
20
38
self . bundleURL ( )
21
39
}
0 commit comments