Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/cold-colts-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@rnx-kit/react-native-host": patch
---

Fixed community JSC support.

Fix compile error in `ReactNativeHost.mm` when Hermes is not being used.
`fatal error: 'ReactCommon/RCTHermesInstance.h' file not found`

The `USE_HERMES` preprocessor definition was only being set in
`GCC_PREPROCESSOR_DEFINITIONS` (for C and Objective-C files), but NOT in
`CPP_PREPROCESSOR_DEFINITIONS` (for [Objective] C++) files. This caused
`ReactNativeHost.mm` to NOT receive the `USE_HERMES=0` flag, making it
incorrectly import Hermes symbols that aren't resolved at link time.
5 changes: 4 additions & 1 deletion packages/react-native-host/ReactNativeHost.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ repo_dir = repository['directory']

new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
preprocessor_definitions = [
'$(inherit)',
'$(inherited)',
"USE_HERMES=#{ENV['USE_HERMES'] || '0'}",
"USE_THIRD_PARTY_JSC=#{ENV['USE_THIRD_PARTY_JSC'] || '0'}",
"USE_V8=#{ENV['USE_V8'] || '0'}",
]
if new_arch_enabled
preprocessor_definitions << 'RCT_NEW_ARCH_ENABLED=1'
Expand Down Expand Up @@ -49,6 +51,7 @@ Pod::Spec.new do |s|
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++20',
'DEFINES_MODULE' => 'YES',
'GCC_PREPROCESSOR_DEFINITIONS' => preprocessor_definitions,
'CPP_PREPROCESSOR_DEFINITIONS' => preprocessor_definitions,
'HEADER_SEARCH_PATHS' => [
'$(PODS_ROOT)/Headers/Private/React-Core',
'$(PODS_CONFIGURATION_BUILD_DIR)/React-RuntimeApple/React_RuntimeApple.framework/Headers',
Expand Down
8 changes: 6 additions & 2 deletions packages/react-native-host/cocoa/RNXBridgelessHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@

#if USE_HERMES
#import <ReactCommon/RCTHermesInstance.h>
#elif USE_V8
#import <v8runtime/V8ExecutorFactory.h>
#elif __has_include(<React-jsc/RCTJscInstance.h>)
#import <React-jsc/RCTJscInstance.h>
#else
#import <ReactCommon/RCTJscInstance.h>
#endif // USE_HERMES
#import <ReactCommon/RCTJscInstance.h> // RN pre 0.80
#endif // USE_HERMES

#ifdef USE_REACT_NATIVE_CONFIG
#import <react/config/ReactNativeConfig.h>
Expand Down
6 changes: 4 additions & 2 deletions packages/react-native-host/cocoa/ReactNativeHost.mm
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,11 @@ - (void)initializeReactHost
#else
return std::make_shared<facebook::react::RCTHermesInstance>(nullptr, false);
#endif // USE_REACT_NATIVE_CONFIG
#else // USE_HERMES
#elif USE_V8
return std::make_shared<facebook::react::V8ExecutorFactory>();
#else
return std::make_shared<facebook::react::RCTJscInstance>();
#endif // USE_HERMES
#endif
};

__weak __typeof(self) weakSelf = self;
Expand Down