Skip to content

[iOS][swiftpm] stop baking an absolute HERMES_CLI_PATH into the app pbxproj - #58292

Open
chrfalch wants to merge 1 commit into
mainfrom
chrfalch/spm-drop-absolute-hermes-cli-path
Open

[iOS][swiftpm] stop baking an absolute HERMES_CLI_PATH into the app pbxproj#58292
chrfalch wants to merge 1 commit into
mainfrom
chrfalch/spm-drop-absolute-hermes-cli-path

Conversation

@chrfalch

@chrfalch chrfalch commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Summary:

npx react-native spm add writes HERMES_CLI_PATH into the app's committed project.pbxproj — the absolute path of hermesc in the hermes-compiler npm package, as resolved on whichever machine ran the command. So every SwiftPM-converted app commits one developer's disk layout.

Nothing needs it: react-native-xcode.sh already resolves hermesc at build time through react-native's own dependency graph when the current value is not a file. A relative setting can't replace it either — $(REACT_NATIVE_PATH)/../hermes-compiler breaks on a symlinked react-native, and $(SRCROOT)/../node_modules/… breaks on hoisted monorepos.

So this deletes resolveHermesCliPathSetting(), along with the hermesCliPath parameter it fed on injectSpmIntoPbxproj and mergeReactBuildSettings. Already-injected projects self-clean on the next spm add/update, which strips every scalar recorded in .spm-injected.json before re-injecting.

Scope: SwiftPM only

Both pieces involved arrived with SwiftPM in #57332 and first shipped in 0.87.0 — scripts/spm/generate-spm-xcodeproj.js (the whole file, including the write) and the NODE_HERMESC build-time fallback in react-native-xcode.sh.

Everything CocoaPods relies on is older and untouched, all present in 0.86.0: the pod-derived HERMES_CLI_PATH default, the "hermesc could not be found" error, and the hermesc -emit-binary call. A CocoaPods build cannot be affected by this change.

That parameter shipped in 0.87.0 and 0.87.1, but SwiftPM is Preview-labelled, so removing it is in scope. Nothing in the repo passed it except the deleted resolver.

Known limitation

The fallback is gated on PODS_ROOT being absent, so a SwiftPM app that keeps side-by-side non-RN pods skips it and needs an explicit HERMES_CLI_PATH. Evaluating that gate verbatim out of the unchanged script:

app gate hermesc
no Pods/ (normal SwiftPM app) fires from node_modules
Pods/, non-RN pods only skipped pod path — absent
Pods/ with hermes-engine skipped the pod's, unchanged

Set it in an xcconfig, not the pbxproj: createdScalars cleanup removes by key, so it would drop a hand-edited value too. Keying the gate on the hermes-engine directory would close this — left as a follow-up so this PR doesn't touch the bundling script.

Changelog:

[IOS] [FIXED] - SwiftPM: stop baking an absolute, machine-specific HERMES_CLI_PATH into the app's pbxproj; resolve hermesc at build time instead

Test Plan:

Red first — with the source reverted, the new entry-point test fails on a seeded hermes-compiler fixture: ✕ writes no HERMES_CLI_PATH, in any configuration or the marker (1 failed, 76 passed).

yarn jest packages/react-native/scripts/spm --no-cache -i
Test Suites: 18 passed, 18 total
Tests:       835 passed, 835 total

yarn flow-check (0 errors), plus yarn eslint --max-warnings 0 and yarn prettier --check on the four changed files.

End to end: a 0.87.1 SwiftPM app (@shopify/react-native-skia example, no Pods) with the HERMES_CLI_PATH lines removed from its pbxproj builds in Release, the fallback resolving hermesc from node_modules/hermes-compiler. That build ran against an earlier revision of this branch which also widened the shell gate; with no Pods/ it is row 1, where both conditions behave identically. There is no shell test harness, and the script is unchanged here.

🤖 Generated with Claude Code

@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 Sep 2, 2026
@facebook-github-tools facebook-github-tools Bot added p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Sep 2, 2026
@chrfalch
chrfalch force-pushed the chrfalch/spm-drop-absolute-hermes-cli-path branch from 7164f61 to 6793d6f Compare September 3, 2026 07:29
@chrfalch chrfalch changed the title SwiftPM: stop baking an absolute HERMES_CLI_PATH into the app pbxproj [iOS][swiftpm] stop baking an absolute HERMES_CLI_PATH into the app pbxproj Sep 3, 2026
@chrfalch
chrfalch force-pushed the chrfalch/spm-drop-absolute-hermes-cli-path branch 3 times, most recently from c1077b1 to cc6d8dd Compare September 3, 2026 08:17
@chrfalch
chrfalch requested a review from cipolleschi September 3, 2026 08:56
`spm add` wrote the machine-specific absolute path of hermesc from the
hermes-compiler npm package into every build configuration, and apps
commit that pbxproj. react-native-xcode.sh already resolves hermesc at
build time through react-native's own dependency graph, so drop the
write: resolveHermesCliPathSetting() and the hermesCliPath parameter it
fed go with it.

Everything involved arrived with SwiftPM in #57332 and is still
Preview-labelled, so removing the parameter from injectSpmIntoPbxproj
and mergeReactBuildSettings is in scope even though it shipped in
0.87.0/0.87.1. Nothing a CocoaPods build uses is touched: the
pod-derived HERMES_CLI_PATH default, the "hermesc could not be found"
error and the hermesc -emit-binary call all pre-date SwiftPM.
react-native-xcode.sh is unchanged here.

Existing injected projects clean up on the next `spm add`/`update`,
which strips every recorded scalar before re-injecting.

Known gap, deliberately left for a follow-up: the shell fallback is
gated on PODS_ROOT being absent, so a SwiftPM app that keeps
side-by-side non-RN pods never reaches it and needs an explicit
HERMES_CLI_PATH — set in an xcconfig, not the pbxproj, because the
recorded-scalar cleanup is value-blind. Keying that gate on the
hermes-engine pod directory would close it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@chrfalch
chrfalch force-pushed the chrfalch/spm-drop-absolute-hermes-cli-path branch from cc6d8dd to 6439916 Compare September 3, 2026 08:59

@cipolleschi cipolleschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this.

@meta-codesync

meta-codesync Bot commented Sep 3, 2026

Copy link
Copy Markdown

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D118624244.

@cortinico cortinico left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

Copilot stopped work on behalf of rachel11026725 due to an error September 3, 2026 15:42
Copilot stopped work on behalf of rachel11026725 due to an error September 3, 2026 15:42
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. p: Expo Partner: Expo Partner 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.

3 participants