diff --git a/.changeset/plenty-moose-live.md b/.changeset/plenty-moose-live.md new file mode 100644 index 0000000000..319680bc0d --- /dev/null +++ b/.changeset/plenty-moose-live.md @@ -0,0 +1,5 @@ +--- +"@rnx-kit/react-native-host": patch +--- + +Override feature flags for bridgeless mode diff --git a/packages/react-native-host/cocoa/RNXBridgelessHeaders.h b/packages/react-native-host/cocoa/RNXBridgelessHeaders.h index dd8a69988b..6fe3778bdb 100644 --- a/packages/react-native-host/cocoa/RNXBridgelessHeaders.h +++ b/packages/react-native-host/cocoa/RNXBridgelessHeaders.h @@ -12,6 +12,12 @@ #import +#if __has_include() +#import +#import +#define USE_FEATURE_FLAGS +#endif // __has_include() + #if __has_include() using SharedJSRuntimeFactory = std::shared_ptr; #else @@ -42,6 +48,28 @@ using SharedJSRuntimeFactory = std::shared_ptr diff --git a/packages/react-native-host/cocoa/ReactNativeHost.mm b/packages/react-native-host/cocoa/ReactNativeHost.mm index fe905d7e6a..e27f81a194 100644 --- a/packages/react-native-host/cocoa/ReactNativeHost.mm +++ b/packages/react-native-host/cocoa/ReactNativeHost.mm @@ -49,6 +49,23 @@ - (instancetype)initWithConfig:(id)config - (instancetype)initWithConfig:(id)config launchOptions:(NSDictionary *)launchOptions { if (self = [super init]) { + _config = config; + _launchOptions = launchOptions; + [self enableTurboModule]; + _isShuttingDown = [[NSLock alloc] init]; + + if ([config respondsToSelector:@selector(shouldReleaseBridgeWhenBackgrounded)] && + [config shouldReleaseBridgeWhenBackgrounded]) { + _hostReleaser = [[RNXHostReleaser alloc] initWithHost:self]; + } + +#ifdef USE_FEATURE_FLAGS + if (self.isBridgelessEnabled) { + facebook::react::ReactNativeFeatureFlags::override( + std::make_unique()); + } +#endif // USE_FEATURE_FLAGS + if ([config respondsToSelector:@selector(isDevLoadingViewEnabled)]) { RCTDevLoadingViewSetEnabled([config isDevLoadingViewEnabled]); } @@ -69,16 +86,6 @@ - (instancetype)initWithConfig:(id)config launchOptions:(NSDictio }); } - _config = config; - _launchOptions = launchOptions; - [self enableTurboModule]; - _isShuttingDown = [[NSLock alloc] init]; - - if ([config respondsToSelector:@selector(shouldReleaseBridgeWhenBackgrounded)] && - [config shouldReleaseBridgeWhenBackgrounded]) { - _hostReleaser = [[RNXHostReleaser alloc] initWithHost:self]; - } - [self initializeReactHost]; } return self;