Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions examples/bare/ios/BareExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}

Expand Down
17 changes: 17 additions & 0 deletions examples/bare/ios/BareExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@
<string></string>
<key>RCTNewArchEnabled</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
Loading