Commit 2d81437
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: 1db7aecbd1d13fd52ad45aadff1bd0c1a61682361 parent 7516d74 commit 2d81437
File tree
2 files changed
+5
-1
lines changed- packages/react-native
- Libraries/AppDelegate
- scripts
2 files changed
+5
-1
lines changedLines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
0 commit comments