Skip to content

fix: JSC support — createJSRuntimeFactory compile error & Hermes pods not excluded#55817

Open
tux2nicolae wants to merge 2 commits intofacebook:mainfrom
crisposoft:fix/jsc-createJSRuntimeFactory-compile-error
Open

fix: JSC support — createJSRuntimeFactory compile error & Hermes pods not excluded#55817
tux2nicolae wants to merge 2 commits intofacebook:mainfrom
crisposoft:fix/jsc-createJSRuntimeFactory-compile-error

Conversation

@tux2nicolae
Copy link

@tux2nicolae tux2nicolae commented Feb 28, 2026

Changelog:

[iOS] [Fixed] - Fix compilation error in createJSRuntimeFactory and skip Hermes pods when USE_THIRD_PARTY_JSC is enabled

Summary

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 #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

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)

When USE_THIRD_PARTY_JSC is set to 1, the #if block is skipped entirely,
leaving createJSRuntimeFactory as a non-void function with no return
statement, which causes a compilation error.

Add an #else branch that raises an NSException (indicating subclasses
must override this method) and returns nil to satisfy the compiler.
@meta-cla
Copy link

meta-cla bot commented Feb 28, 2026

Hi @tux2nicolae!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla
Copy link

meta-cla bot commented Feb 28, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 28, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Feb 28, 2026
The hermes_enabled flag in use_react_native! was hardcoded to true,
causing hermes-engine, React-hermes, and React-RuntimeHermes pods to
always be installed even when USE_THIRD_PARTY_JSC=1.

This change reads the USE_THIRD_PARTY_JSC environment variable via
use_third_party_jsc() so that Hermes pods are excluded when a
third-party JSC engine is configured.

Fixes: facebook#54268
@tux2nicolae tux2nicolae changed the title fix: add #else branch to createJSRuntimeFactory when USE_THIRD_PARTY_JSC is enabled fix: JSC support — createJSRuntimeFactory compile error & Hermes pods not excluded Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cocoapod scripts add hermes dependency even when JSC is used

2 participants