Skip to content

Conversation

@tsapeta
Copy link
Contributor

@tsapeta tsapeta commented Dec 17, 2025

Summary:

Currently, there are two delegate protocols related to the RCTHost class that Frameworks can use: RCTHostDelegate and RCTHostRuntimeDelegate.
RCTHostDelegate is easy to set and use as RCTReactNativeFactory already conforms to it. However, using the RCTHostRuntimeDelegate is less convenient because it can only be set via the host's runtimeDelegate property. This requires access to the host instance first, which in turn means having to wait for hostDidStart (see how we currently do this in Expo: https://github.com/expo/expo/blob/cacd14059830c00971d90d39cf8aa9e67f5e6de1/packages/expo/ios/AppDelegates/ExpoReactNativeFactory.mm#L28-L36).
Additionally it's not clear that hostDidStart is called before host:didInitializeRuntime, especially since both are called from different threads. Relying on this ordering feels unsafe to me.
I'm proposing to merge RCTHostRuntimeDelegate into RCTHostDelegate as they effectively serve the same purpose.

As part of this change, I've deprecated RCTHostRuntimeDelegate and its method. It can be removed in 0.85 or 0.86, depending on which release allows breaking changes. Instead, I've added the same method (optional) to RCTHostDelegate.

All call sites and tests have been updated accordingly.

Changelog:

[IOS] [DEPRECATED] - Deprecate RCTHostRuntimeDelegate and merge into RCTHostDelegate

Test Plan:

  • Manually added host:didInitializeRuntime: to RCTReactNativeFactory and confirmed it gets called
  • Tested this change in Expo and our own factory
  • Native unit tests are passing (for both the deprecated and new method)

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 17, 2025
@facebook-github-bot facebook-github-bot added the p: Expo Partner: Expo label Dec 17, 2025
@tsapeta tsapeta marked this pull request as ready for review December 19, 2025 23:30
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Dec 20, 2025
Copy link
Contributor

@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.

Thanks for the changes, I added a question... I'd rather not introduce #ifdef __cplusplus if possible

isFatal:(BOOL)isFatal
extraData:(NSDictionary<NSString *, id> *)extraData __attribute__((deprecated));

#ifdef __cplusplus
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this?
The method was already in the header, so it should not be required. The only problem i can see is that, as of now, RCTHostDelegate can be used in Swift without C++ interop. With this addition, Swift can't use the RCTHostDelegate anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was not necessary to work, so I've removed it.
In general, as we mostly consume React Native APIs from Swift, we found it really annoying that some headers are not accessible from Swift at all and we have to build wrappers in Objective-C to work around it. It's usually fine if some methods are hidden for Swift, but things are harder if the entire class or protocol is unavailable. It would be nice if I could make this better someday.

@tsapeta tsapeta force-pushed the @tsapeta/merge-runtime-delegate-into-host-delegate branch from e3af298 to 13f406a Compare January 31, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Expo Partner: Expo p: Software Mansion Partner: Software Mansion Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants