Skip to content

Commit

Permalink
fix(react-native-host): update feature flags for 0.77 (#3443)
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 authored Dec 10, 2024
1 parent b6f4e7e commit 582dabc
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/itchy-cameras-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rnx-kit/react-native-host": patch
---

Updated feature flags and other build fixes for 0.77
27 changes: 27 additions & 0 deletions packages/react-native-host/cocoa/RNXBridgelessHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,36 @@ using SharedJSRuntimeFactory = std::shared_ptr<facebook::react::JSRuntimeFactory
@end

#ifdef USE_FEATURE_FLAGS
#if __has_include(<React-RCTAppDelegate/RCTArchConfiguratorProtocol.h>) || __has_include(<React_RCTAppDelegate/RCTArchConfiguratorProtocol.h>)
#define USE_UNIFIED_FEATURE_FLAGS 1
#endif // __has_include(<React-RCTAppDelegate/RCTArchConfiguratorProtocol.h>)

// 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;
Expand All @@ -67,6 +93,7 @@ class RNXBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlag
{
return true;
}
#endif // USE_UNIFIED_FEATURE_FLAGS
};
#endif // USE_FEATURE_FLAGS

Expand Down
4 changes: 4 additions & 0 deletions packages/react-native-host/cocoa/RNXTurboModuleAdapter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ - (Class)getModuleClassFromName:(char const *)name

- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
{
#if __has_include(<React-RCTAppDelegate/RCTDependencyProvider.h>) || __has_include(<React_RCTAppDelegate/RCTDependencyProvider.h>)
return RCTAppSetupDefaultModuleFromClass(moduleClass, nil);
#else
return RCTAppSetupDefaultModuleFromClass(moduleClass);
#endif // __has_include(<React-RCTAppDelegate/RCTArchConfiguratorProtocol.h>)
}

// MARK: - Private
Expand Down
5 changes: 1 addition & 4 deletions packages/react-native-host/cocoa/ReactNativeHost+View.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-host/cocoa/ReactNativeHost.mm
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ - (void)initializeReactHost
}

#if USE_BRIDGELESS
#ifndef USE_UNIFIED_FEATURE_FLAGS
RCTSetUseNativeViewConfigsInBridgelessMode(YES);
#endif
RCTEnableTurboModuleInterop(YES);
RCTEnableTurboModuleInteropBridgeProxy(YES);

Expand Down

0 comments on commit 582dabc

Please sign in to comment.