diff --git a/template/ios/HelloWorld/AppDelegate.swift b/template/ios/HelloWorld/AppDelegate.swift index 86b299b..0d3565b 100644 --- a/template/ios/HelloWorld/AppDelegate.swift +++ b/template/ios/HelloWorld/AppDelegate.swift @@ -4,18 +4,36 @@ import React_RCTAppDelegate import ReactAppDependencyProvider @main -class AppDelegate: RCTAppDelegate { - override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { - self.moduleName = "HelloWorld" - self.dependencyProvider = RCTAppDependencyProvider() +class AppDelegate: UIResponder, UIApplicationDelegate { + var window: UIWindow? - // You can add your custom initial props in the dictionary below. - // They will be passed down to the ViewController used by React Native. - self.initialProps = [:] + var reactNativeDelegate: ReactNativeDelegate? + var reactNativeFactory: RCTReactNativeFactory? - return super.application(application, didFinishLaunchingWithOptions: launchOptions) + func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil + ) -> Bool { + let delegate = ReactNativeDelegate() + let factory = RCTReactNativeFactory(delegate: delegate) + delegate.dependencyProvider = RCTAppDependencyProvider() + + reactNativeDelegate = delegate + reactNativeFactory = factory + + window = UIWindow(frame: UIScreen.main.bounds) + + factory.startReactNative( + withModuleName: "HelloWorld", + in: window, + launchOptions: launchOptions + ) + + return true } +} +class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate { override func sourceURL(for bridge: RCTBridge) -> URL? { self.bundleURL() }