Skip to content

Commit 2d81437

Browse files
tux2nicolaemeta-codesync[bot]
authored andcommitted
fix: JSC support — createJSRuntimeFactory compile error & Hermes pods not excluded (facebook#55817)
Summary: ## Changelog: [iOS] [Fixed] - Fix compilation error in `createJSRuntimeFactory` and skip Hermes pods when `USE_THIRD_PARTY_JSC` is enabled Two fixes for third-party JSC engine support (`USE_THIRD_PARTY_JSC=1`): ### 1. `createJSRuntimeFactory` missing return path When `USE_THIRD_PARTY_JSC` is set to `1`, the `#if USE_THIRD_PARTY_JSC != 1` block in `createJSRuntimeFactory` is skipped entirely. Since there is no `#else` branch, the method — which returns `JSRuntimeFactoryRef` (a non-void type) — has no return statement on that code path, causing a **compilation error**. **Fix:** Added an `#else` branch that raises an `NSException` (indicating subclasses must override this method) and returns `nil` to satisfy the compiler. ### 2. Hermes pods always installed despite `USE_THIRD_PARTY_JSC=1` The `hermes_enabled` flag in `use_react_native!` (`react_native_pods.rb`) is **hardcoded to `true`**, completely ignoring the `USE_THIRD_PARTY_JSC` environment variable. This causes `hermes-engine`, `React-hermes`, and `React-RuntimeHermes` to always be installed — even when a third-party JSC engine is configured — bloating the binary with an unused JS engine. **Fix:** Changed `hermes_enabled= true` to `hermes_enabled= !use_third_party_jsc()` so Hermes pods are excluded when `USE_THIRD_PARTY_JSC=1`. Fixes facebook#54268 ## Changes - `RCTDefaultReactNativeFactoryDelegate.mm`: Added `#else` branch to `createJSRuntimeFactory` - `react_native_pods.rb`: Set `hermes_enabled` based on `use_third_party_jsc()` instead of hardcoding `true` ## Motivation Projects using third-party JSC (e.g. via `react-native-community/javascriptcore`) set `USE_THIRD_PARTY_JSC=1`. Without these fixes: 1. The code fails to compile because the non-void function `createJSRuntimeFactory` has no return statement in the JSC path 2. Hermes engine pods are still installed and bundled, adding unnecessary binary size — particularly problematic for iOS App Clips which have a strict 15MB size limit Pull Request resolved: facebook#55817 Test Plan: - Verified `pod install` with `USE_THIRD_PARTY_JSC=1` correctly excludes `hermes-engine`, `React-hermes`, and `React-RuntimeHermes` (130 pods instead of 133) - Verified `Podfile.lock` no longer references Hermes pods - Verified the project compiles successfully with `USE_THIRD_PARTY_JSC=1` - Verified the project compiles successfully without `USE_THIRD_PARTY_JSC` (default Hermes path unchanged) Reviewed By: cortinico Differential Revision: D95034757 Pulled By: cipolleschi fbshipit-source-id: 1db7aecbd1d13fd52ad45aadff1bd0c1a6168236
1 parent 7516d74 commit 2d81437

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ - (JSRuntimeFactoryRef)createJSRuntimeFactory
4545
{
4646
#if USE_THIRD_PARTY_JSC != 1
4747
return jsrt_create_hermes_factory();
48+
#else
49+
[NSException raise:@"JSRuntimeFactory"
50+
format:@"createJSRuntimeFactory must be overridden when using third-party JSC"];
51+
return nil;
4852
#endif
4953
}
5054

packages/react-native/scripts/react_native_pods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def use_react_native! (
7878
react_native_path = Pod::Config.instance.installation_root.join(path)
7979
prefix = react_native_path.relative_path_from(Pod::Config.instance.installation_root)
8080

81-
hermes_enabled= true
81+
hermes_enabled= !use_third_party_jsc()
8282
# Set the app_path as env variable so the podspecs can access it.
8383
ENV['APP_PATH'] = app_path
8484
ENV['REACT_NATIVE_PATH'] = react_native_path.to_s

0 commit comments

Comments
 (0)