Skip to content

iOS SceneDelegate migration proposal#967

Open
artus9033 wants to merge 7 commits intoreact-native-community:mainfrom
artus9033:artus9033/scenedelegate
Open

iOS SceneDelegate migration proposal#967
artus9033 wants to merge 7 commits intoreact-native-community:mainfrom
artus9033:artus9033/scenedelegate

Conversation

@artus9033
Copy link

@artus9033 artus9033 commented Dec 16, 2025

A proposal for adding SceneDelegate support to iOS.

View the rendered RFC

@artus9033 artus9033 force-pushed the artus9033/scenedelegate branch from 9c54321 to 2d3189d Compare December 16, 2025 17:20
Copy link

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job here!
I left a bunch of comments that should be applied/adressed in the RFC.

Make sure not to have any RN acronym. In official documentation we always use the full React Native product name.

Comment on lines 131 to 137
#### Migrating Dimensions: internal state adjustment & naming convention

Dimensions currently are exported as a constant. Such design does not fit the concept of resizable windows. To accommodate this, `RCTDeviceInfo` (iOS native module) should update its internal state variable upon changes to the frame so as to make `getConstants` return a value that is up-to-date at the time of invocation.

`Dimensions` (JS API) contains a `getConstants` method that wraps the native `getConstants` method and caches the result internally. The caching would now be obsolete (since the value may change in time), therefore the underlying native method should always be invoked. Moreover, the naming of the JS `getConstants` method in face of resizable windows may be misleading, since from now on the dimensions are not constant. Therefore, I propose a gradual adoption of a new method of same functionality, `getInfo()`, along with the deprecation of `getConstants()`, on the JS API side. A rough draft of the JS API changes would be:

![](assets/0000-nativedeviceinfo-api.png)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is actually required for the SceneDelegate migration. probably we can move it to a different RFC/effort

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I will move it from here, then

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened a separate RFC to track this idea: #969 - CC @cipolleschi

@artus9033 artus9033 force-pushed the artus9033/scenedelegate branch from 7301b34 to e343215 Compare December 18, 2025 14:58
@artus9033
Copy link
Author

Thank you for the comments Riccardo! Yes, sorry for not using the full name of React Native - I will keep that in mind. I think the RFC is now ready for a re-review, I applied your suggestions and also reworded few sections.

Adoption of `UIScene` lifecycle requires the following actions:

* In application base code
* migration from `AppDelegate` as the primary point of lifecycle-related logic to `SceneDelegate`; for backwards compatibility, React Native's public API integration points will still be compatible with `AppDelegate` approach for users that may not want to migrate immediately

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it would be ok to not have that backwards compatibility. The Delegate is on a clock anyway that we do not control, so everyone NEEDS to migrate, and keeping the old approach around is just delaying an inevitable that will be significantly more painful then and we would need to live the double life in the mean time supporting both approaches.
Might be best to just say, from this version of RN, in order to be compliant with Apple's requirements, we are moving off, older versions not affected. Just being clear in the comms with the framework end users

Copy link
Author

@artus9033 artus9033 Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree on the point that this has to be removed at some stage, yet the objective I had in mind was to bring an additive, non-breaking change. We should definitely deprecate those methods, but a sudden removal would make an unpleasant surprise for the users. By deprecating, we make it a gentle migration and we'll get to removal anyway.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Parsa. It is better to do this properly once rather than carrying things forward just for backward compatibility. Many things in the core break over time without being visible to us, and this is not an exception.

Another issue is the terminology itself. In the React Native ecosystem, the term “users” is often used to refer to consumers of a package, which easily causes confusion. In our case, those “users” are developers, not end users. Since the audience is developers, they are expected to adapt to changes and learn new patterns. We are not building a product for non-technical end customers.

Copy link
Author

@artus9033 artus9033 Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sharing that, then I think the matter is up to be discussed. WDYT @cipolleschi ?

Regarding the "users", definitely the user persona I was referring to in this context was the developer - yet, I'll keep in mind that the default meaning here is the end user, thank you for noting that!

@objectiveSee
Copy link

Hey, this is great work. I'm exploring CarPlay support in a React Native/Expo app where CarPlay would be implemented natively in Swift using CPTemplate APIs, while the main app stays in React Native.

A few questions about the proposed API:

  1. Will RCTReactNativeFactory gracefully handle scenes it doesn't manage? In my case, the CarPlay scene would be pure Swift with no React Native involvement.

  2. Should the factory be instantiated globally or only for React Native-managed scenes?

  3. Any caveats for scene role routing when some scenes bypass React Native entirely?

@artus9033
Copy link
Author

Hey, this is great work. I'm exploring CarPlay support in a React Native/Expo app where CarPlay would be implemented natively in Swift using CPTemplate APIs, while the main app stays in React Native.

A few questions about the proposed API:

Thank you, it's a pleasure to hear that! Regarding your questions:

  1. Will RCTReactNativeFactory gracefully handle scenes it doesn't manage? In my case, the CarPlay scene would be pure Swift with no React Native involvement.

I think it should not collide in any way, since scene management happens in the driver code of your application:

- (void)scene:(UIScene *)scene
    willConnectToSession:(UISceneSession *)session
                 options:(UISceneConnectionOptions *)connectionOptions
{
  // ...
  RCTReactNativeFactory *factory = [[RCTReactNativeFactory alloc] initWithDelegate:delegate];
  // ...
  [factory startReactNativeWithModuleName:@"RNTesterApp"
                                 inWindow:self.window
                        initialProperties:[self prepareInitialProps]
                        connectionOptions:connectionOptions];
}

That said, React Native operates only in the window in the scene you start it with.

  1. Should the factory be instantiated globally or only for React Native-managed scenes?

I think this is a question more related to brownfield, this PR does not change anything w.r.t. the previous state, but anyway the factory should be initialized once from what I remember - as in this piece of code in react-native-brownfield.

  1. Any caveats for scene role routing when some scenes bypass React Native entirely?

Just to confirm, by that you mean creating some scene roles that never have anything to do with React Native? I haven't done any experiments in such a scenario, but don't foresee anything that would break - the code path for initializing the RN scene would just never be hit, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments