Skip to content

Commit

Permalink
fix(react-native-host): handle refactorings in 0.74 (#2916)
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 authored Jan 12, 2024
1 parent c01ddf3 commit 476ebe8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-kids-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rnx-kit/react-native-host": patch
---

Handle refactorings in 0.74
2 changes: 1 addition & 1 deletion packages/react-native-host/ReactNativeHost.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = package['version']
repository = package['repository']
repo_dir = repository['directory']

new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1' && ENV['USE_NEW_ARCH'] != '0'
preprocessor_definitions = [
'FOLLY_CFG_NO_COROUTINES=1',
'FOLLY_HAVE_CLOCK_GETTIME=1',
Expand Down
31 changes: 12 additions & 19 deletions packages/react-native-host/cocoa/RNXTurboModuleAdapter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,26 @@

#if __has_include(<React/RCTAppSetupUtils.h>) // <0.72
#import <React/RCTAppSetupUtils.h>
#define USE_RUNTIME_SCHEDULER 0
#else
#import <React-RCTAppDelegate/RCTAppSetupUtils.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>

// We still get into this path because react-native-macos 0.71 picked up some
// 0.72 bits. AFAICT, `RCTLegacyInteropComponents.h` is a new addition in 0.72
// in both react-native and react-native-macos.
#if __has_include(<React-RCTAppDelegate/RCTLegacyInteropComponents.h>)
// 0.72 bits. AFAICT, `SchedulerPriorityUtils.h` is a new addition in 0.72 in
// both react-native and react-native-macos.
#if __has_include(<react/renderer/runtimescheduler/SchedulerPriorityUtils.h>)
#if __has_include(<React-RCTAppDelegate/RCTLegacyInteropComponents.h>) // <0.74
#import <React-RCTAppDelegate/RCTLegacyInteropComponents.h>
#define MANUALLY_REGISTER_LEGACY_COMPONENTS 1
#endif // __has_include(<React-RCTAppDelegate/RCTLegacyInteropComponents.h>)
#import <React/RCTLegacyViewManagerInteropComponentView.h>
#import <react/renderer/runtimescheduler/RuntimeScheduler.h>
#import <react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h>
#if __has_include(<React/RCTRuntimeExecutorFromBridge.h>)
#import <React/RCTRuntimeExecutorFromBridge.h>
#endif // __has_include(<React/RCTRuntimeExecutorFromBridge.h>)
#define SUPPORTS_LEGACY_COMPONENTS 1
#define USE_RUNTIME_SCHEDULER 1
#else
#define SUPPORTS_LEGACY_COMPONENTS 0
#define USE_RUNTIME_SCHEDULER 0
#endif // __has_include(<React-RCTAppDelegate/RCTLegacyInteropComponents.h>)
#endif // __has_include(<react/renderer/runtimescheduler/SchedulerPriorityUtils.h>)

#endif // __has_include(<React/RCTAppSetupUtils.h>)

Expand All @@ -52,7 +50,11 @@ @implementation RNXTurboModuleAdapter {
(RCTBridge *)bridge
{
#if USE_TURBOMODULE
[self registerLegacyViewManagers];
#if MANUALLY_REGISTER_LEGACY_COMPONENTS
for (NSString *legacyComponent in [RCTLegacyInteropComponents legacyInteropComponents]) {
[RCTLegacyViewManagerInteropComponentView supportLegacyViewManagerWithName:legacyComponent];
}
#endif // MANUALLY_REGISTER_LEGACY_COMPONENTS
// jsExecutorFactoryForBridge: (USE_TURBOMODULE=1)
return [self initJsExecutorFactoryWithBridge:bridge];
#else
Expand Down Expand Up @@ -104,15 +106,6 @@ - (Class)getModuleClassFromName:(const char *)name
#endif // USE_RUNTIME_SCHEDULER
}

- (void)registerLegacyViewManagers
{
#if SUPPORTS_LEGACY_COMPONENTS
for (NSString *legacyComponent in [RCTLegacyInteropComponents legacyInteropComponents]) {
[RCTLegacyViewManagerInteropComponentView supportLegacyViewManagerWithName:legacyComponent];
}
#endif // SUPPORTS_LEGACY_COMPONENTS
}

#endif // USE_TURBOMODULE

@end

0 comments on commit 476ebe8

Please sign in to comment.