From 582dabc14b2aa9b265f8a5f7530ed1fb8d175166 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:57:30 +0100 Subject: [PATCH] fix(react-native-host): update feature flags for 0.77 (#3443) --- .changeset/itchy-cameras-breathe.md | 5 ++++ .../cocoa/RNXBridgelessHeaders.h | 27 +++++++++++++++++++ .../cocoa/RNXTurboModuleAdapter.mm | 4 +++ .../cocoa/ReactNativeHost+View.mm | 5 +--- .../cocoa/ReactNativeHost.mm | 2 ++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 .changeset/itchy-cameras-breathe.md diff --git a/.changeset/itchy-cameras-breathe.md b/.changeset/itchy-cameras-breathe.md new file mode 100644 index 000000000..2562a26cc --- /dev/null +++ b/.changeset/itchy-cameras-breathe.md @@ -0,0 +1,5 @@ +--- +"@rnx-kit/react-native-host": patch +--- + +Updated feature flags and other build fixes for 0.77 diff --git a/packages/react-native-host/cocoa/RNXBridgelessHeaders.h b/packages/react-native-host/cocoa/RNXBridgelessHeaders.h index 6fe3778bd..14e39f9df 100644 --- a/packages/react-native-host/cocoa/RNXBridgelessHeaders.h +++ b/packages/react-native-host/cocoa/RNXBridgelessHeaders.h @@ -49,10 +49,36 @@ using SharedJSRuntimeFactory = std::shared_ptr) || __has_include() +#define USE_UNIFIED_FEATURE_FLAGS 1 +#endif // __has_include() + // https://github.com/facebook/react-native/blob/0.74-stable/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm#L272-L286 class RNXBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults { public: +#ifdef USE_UNIFIED_FEATURE_FLAGS // >= 0.77 + bool enableBridgelessArchitecture() override + { + return true; + } + bool enableFabricRenderer() override + { + return true; + } + bool useTurboModules() override + { + return true; + } + bool useNativeViewConfigsInBridgelessMode() override + { + return true; + } + bool enableFixForViewCommandRace() override + { + return true; + } +#else // < 0.77 bool useModernRuntimeScheduler() override { return true; @@ -67,6 +93,7 @@ class RNXBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlag { return true; } +#endif // USE_UNIFIED_FEATURE_FLAGS }; #endif // USE_FEATURE_FLAGS diff --git a/packages/react-native-host/cocoa/RNXTurboModuleAdapter.mm b/packages/react-native-host/cocoa/RNXTurboModuleAdapter.mm index 0e9cd8303..6e152bf5a 100644 --- a/packages/react-native-host/cocoa/RNXTurboModuleAdapter.mm +++ b/packages/react-native-host/cocoa/RNXTurboModuleAdapter.mm @@ -98,7 +98,11 @@ - (Class)getModuleClassFromName:(char const *)name - (id)getModuleInstanceFromClass:(Class)moduleClass { +#if __has_include() || __has_include() + return RCTAppSetupDefaultModuleFromClass(moduleClass, nil); +#else return RCTAppSetupDefaultModuleFromClass(moduleClass); +#endif // __has_include() } // MARK: - Private diff --git a/packages/react-native-host/cocoa/ReactNativeHost+View.mm b/packages/react-native-host/cocoa/ReactNativeHost+View.mm index 07066daa8..3a7785d82 100644 --- a/packages/react-native-host/cocoa/ReactNativeHost+View.mm +++ b/packages/react-native-host/cocoa/ReactNativeHost+View.mm @@ -59,10 +59,7 @@ - (RNXView *)viewWithModuleName:(NSString *)moduleName #elif USE_BRIDGELESS RCTFabricSurface *surface = [self.reactHost createSurfaceWithModuleName:moduleName initialProperties:initialProps]; - RCTSurfaceSizeMeasureMode sizeMeasureMode = - RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact; - return [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface - sizeMeasureMode:sizeMeasureMode]; + return [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface]; #else RCTFabricSurface *surface = [[RCTFabricSurface alloc] initWithSurfacePresenter:self.surfacePresenter diff --git a/packages/react-native-host/cocoa/ReactNativeHost.mm b/packages/react-native-host/cocoa/ReactNativeHost.mm index c08900263..b45413a62 100644 --- a/packages/react-native-host/cocoa/ReactNativeHost.mm +++ b/packages/react-native-host/cocoa/ReactNativeHost.mm @@ -248,7 +248,9 @@ - (void)initializeReactHost } #if USE_BRIDGELESS +#ifndef USE_UNIFIED_FEATURE_FLAGS RCTSetUseNativeViewConfigsInBridgelessMode(YES); +#endif RCTEnableTurboModuleInterop(YES); RCTEnableTurboModuleInteropBridgeProxy(YES);