fix: JSC support — createJSRuntimeFactory compile error & Hermes pods not excluded#55817
fix: JSC support — createJSRuntimeFactory compile error & Hermes pods not excluded#55817tux2nicolae wants to merge 2 commits intofacebook:mainfrom
Conversation
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.
|
Hi @tux2nicolae! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
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
Changelog:
[iOS] [Fixed] - Fix compilation error in
createJSRuntimeFactoryand skip Hermes pods whenUSE_THIRD_PARTY_JSCis enabledSummary
Two fixes for third-party JSC engine support (
USE_THIRD_PARTY_JSC=1):1.
createJSRuntimeFactorymissing return pathWhen
USE_THIRD_PARTY_JSCis set to1, the#if USE_THIRD_PARTY_JSC != 1block increateJSRuntimeFactoryis skipped entirely. Since there is no#elsebranch, the method — which returnsJSRuntimeFactoryRef(a non-void type) — has no return statement on that code path, causing a compilation error.Fix: Added an
#elsebranch that raises anNSException(indicating subclasses must override this method) and returnsnilto satisfy the compiler.2. Hermes pods always installed despite
USE_THIRD_PARTY_JSC=1The
hermes_enabledflag inuse_react_native!(react_native_pods.rb) is hardcoded totrue, completely ignoring theUSE_THIRD_PARTY_JSCenvironment variable. This causeshermes-engine,React-hermes, andReact-RuntimeHermesto always be installed — even when a third-party JSC engine is configured — bloating the binary with an unused JS engine.Fix: Changed
hermes_enabled= truetohermes_enabled= !use_third_party_jsc()so Hermes pods are excluded whenUSE_THIRD_PARTY_JSC=1.Fixes #54268
Changes
RCTDefaultReactNativeFactoryDelegate.mm: Added#elsebranch tocreateJSRuntimeFactoryreact_native_pods.rb: Sethermes_enabledbased onuse_third_party_jsc()instead of hardcodingtrueMotivation
Projects using third-party JSC (e.g. via
@react-native-community/javascriptcore) setUSE_THIRD_PARTY_JSC=1. Without these fixes:createJSRuntimeFactoryhas no return statement in the JSC pathTest Plan
pod installwithUSE_THIRD_PARTY_JSC=1correctly excludeshermes-engine,React-hermes, andReact-RuntimeHermes(130 pods instead of 133)Podfile.lockno longer references Hermes podsUSE_THIRD_PARTY_JSC=1USE_THIRD_PARTY_JSC(default Hermes path unchanged)