feat: Implement UIScene lifecycle for iOS #54763
Open
+122
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: Implement UIScene lifecycle for iOS
Summary
This PR implements UIScene lifecycle support for React Native on iOS, resolving the warning:
CLIENT OF UIKIT REQUIRES UPDATE: This process does not adopt UIScene lifecycle. This will become an assert in a future version.Fixes #54739
Problem
Starting with iOS 13, Apple introduced the UIScene lifecycle to support multi-window applications and better separate UI concerns from application-level concerns. React Native's
RCTAppDelegatecurrently doesn't support this modern lifecycle, causing a warning that Apple has indicated will eventually become an assertion (app crash) in future iOS versions.Solution
This PR adds UIScene lifecycle support to
RCTAppDelegatewhile maintaining backward compatibility:Changes Made
1. Modified
RCTAppDelegate.happlication:configurationForConnectingSceneSession:options:method declarationAPI_AVAILABLE(ios(13.0))for backward compatibility2. Modified
RCTAppDelegate.mmUISceneConfigurationthat specifiesRCTSceneDelegateas the scene delegate class3. Created
RCTSceneDelegate.hUIWindowSceneDelegateAPI_AVAILABLE(ios(13.0))4. Created
RCTSceneDelegate.mmscene:willConnectToSession:options:- Sets up the window and React Native root viewsceneDidDisconnect:- Handles scene disconnectionsceneDidBecomeActive:- Scene activation handlingsceneWillResignActive:- Scene deactivation handlingsceneWillEnterForeground:- Foreground transitionsceneDidEnterBackground:- Background transitionRCTAppDelegateto accessRCTReactNativeFactoryandRCTRootViewFactory5. Updated
RNTester/Info.plistUIApplicationSceneManifestconfigurationKey Design Decisions
Backward Compatibility: All UIScene-related code is guarded with
API_AVAILABLE(ios(13.0)), ensuring apps targeting iOS < 13 continue to work.Opt-in Approach: UIScene support is activated only when apps include the
UIApplicationSceneManifestin their Info.plist. Existing apps without this configuration continue using the traditional app delegate lifecycle.Integration with Existing Architecture: The
RCTSceneDelegateaccesses the app delegate to retrieve theRCTReactNativeFactory, maintaining consistency with the existing React Native initialization flow.No Breaking Changes: Existing apps using
RCTAppDelegatewithout UIScene configuration will continue to work exactly as before.Testing
Manual Testing Performed
Expected Behavior
Before this PR:
CLIENT OF UIKIT REQUIRES UPDATE: This process does not adopt UIScene lifecycleAfter this PR:
UIApplicationSceneManifestis present in Info.plistMigration Guide for Users
For New Apps
Include the following in your
Info.plist:For Existing Apps
Option 1: Adopt UIScene (Recommended for iOS 13+)
UIApplicationSceneManifestconfiguration above to your Info.plistRCTAppDelegateOption 2: Continue with Traditional Lifecycle
Changelog
[iOS] [Added] - Implement UIScene lifecycle support for iOS 13+
Additional Notes
RCTAppDelegateclass is marked as deprecated in favor ofRCTReactNativeFactory, but this PR adds UIScene support to maintain compatibility for existing usersReact-RCTAppDelegate.podspec) automatically includes new.hand.mmfiles viapodspec_sources, so no podspec changes were neededScreenshots
UIScene lifecycle adopted successfully - no warnings in Xcode console
Reviewers: @cipolleschi @huntie @cortinico
Please let me know if you'd like any changes to this implementation or if you prefer a different approach!