diff --git a/examples/bare/ios/BareExample/AppDelegate.swift b/examples/bare/ios/BareExample/AppDelegate.swift index 80abc7d9..aae32a3a 100644 --- a/examples/bare/ios/BareExample/AppDelegate.swift +++ b/examples/bare/ios/BareExample/AppDelegate.swift @@ -5,11 +5,17 @@ import ReactAppDependencyProvider @main class AppDelegate: UIResponder, UIApplicationDelegate { + /// The scene's window, kept here too for code that still reads + /// `UIApplication.shared.delegate?.window`. var window: UIWindow? var reactNativeDelegate: ReactNativeDelegate? var reactNativeFactory: RCTReactNativeFactory? + /// React Native starts in the window `SceneDelegate` creates: since iOS 27 + /// an app that has not adopted the UIScene lifecycle is stopped at launch + /// (`_UIApplicationEvaluateRuntimeIssueForNoSceneLifecycleAdoption`), and + /// `Info.plist` declares the one scene this app has. func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil @@ -23,15 +29,38 @@ class AppDelegate: UIResponder, UIApplicationDelegate { reactNativeDelegate = delegate reactNativeFactory = factory - window = UIWindow(frame: UIScreen.main.bounds) + return true + } +} + +/// Creates the app's one window and starts React Native in it. +/// +/// It forwards no URLs to React Native: neither `connectionOptions.urlContexts` +/// at launch nor `scene(_:openURLContexts:)` later, so `Linking` sees none on +/// iOS. This app registers no URL scheme; the e2e steers its iOS launches +/// through launch arguments (`e2e/scenario.ts`). An app that opens URLs hands +/// both to `RCTLinkingManager`. +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + var window: UIWindow? + + func scene( + _ scene: UIScene, + willConnectTo session: UISceneSession, + options connectionOptions: UIScene.ConnectionOptions + ) { + guard let windowScene = scene as? UIWindowScene, + let appDelegate = UIApplication.shared.delegate as? AppDelegate else { + return + } + let window = UIWindow(windowScene: windowScene) + self.window = window + appDelegate.window = window - factory.startReactNative( + appDelegate.reactNativeFactory?.startReactNative( withModuleName: "BareExample", in: window, - launchOptions: launchOptions + launchOptions: nil ) - - return true } } diff --git a/examples/bare/ios/BareExample/Info.plist b/examples/bare/ios/BareExample/Info.plist index 56f52a92..fc18ce1e 100644 --- a/examples/bare/ios/BareExample/Info.plist +++ b/examples/bare/ios/BareExample/Info.plist @@ -37,6 +37,23 @@ RCTNewArchEnabled + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + UILaunchStoryboardName LaunchScreen UIRequiredDeviceCapabilities