@@ -2,33 +2,51 @@ import UIKit
22import React
33import React_RCTAppDelegate
44import ReactAppDependencyProvider
5-
5+
66@main
7- class AppDelegate : RCTAppDelegate {
8- override func application( _ application: UIApplication , didFinishLaunchingWithOptions launchOptions: [ UIApplication . LaunchOptionsKey : Any ] ? = nil ) -> Bool {
9- self . moduleName = " OrientationDirectorExample "
10- self . dependencyProvider = RCTAppDependencyProvider ( )
11-
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 = [ : ]
15-
16- return super. application ( application, didFinishLaunchingWithOptions: launchOptions)
7+ class AppDelegate : UIResponder , UIApplicationDelegate {
8+ var window : UIWindow ?
9+
10+ var reactNativeDelegate : ReactNativeDelegate ?
11+ var reactNativeFactory : RCTReactNativeFactory ?
12+
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: " OrientationDirectorExample " ,
28+ in: window,
29+ launchOptions: launchOptions
30+ )
31+
32+ return true
1733 }
18-
34+
35+ func application( _ application: UIApplication , supportedInterfaceOrientationsFor window: UIWindow ? ) -> UIInterfaceOrientationMask {
36+ return OrientationDirector . getSupportedInterfaceOrientationsForWindow ( )
37+ }
38+ }
39+
40+ class ReactNativeDelegate : RCTDefaultReactNativeFactoryDelegate {
1941 override func sourceURL( for bridge: RCTBridge ) -> URL ? {
2042 self . bundleURL ( )
2143 }
22-
44+
2345 override func bundleURL( ) -> URL ? {
2446#if DEBUG
2547 RCTBundleURLProvider . sharedSettings ( ) . jsBundleURL ( forBundleRoot: " index " )
2648#else
2749 Bundle . main. url ( forResource: " main " , withExtension: " jsbundle " )
2850#endif
2951 }
30-
31- override func application( _ application: UIApplication , supportedInterfaceOrientationsFor window: UIWindow ? ) -> UIInterfaceOrientationMask {
32- return OrientationDirector . getSupportedInterfaceOrientationsForWindow ( )
33- }
3452}
0 commit comments