Skip to content

Run SPM-generated shell scripts under bash, not /bin/sh - #58362

Open
lazerg wants to merge 1 commit into
react:mainfrom
lazerg:fix/issue-58359-spm-bash-shell
Open

Run SPM-generated shell scripts under bash, not /bin/sh#58362
lazerg wants to merge 1 commit into
react:mainfrom
lazerg:fix/issue-58359-spm-bash-shell

Conversation

@lazerg

@lazerg lazerg commented Sep 6, 2026

Copy link
Copy Markdown

Summary:

SPM setup scripts start with set -euo pipefail, but every one of them runs under /bin/sh. On a machine where /bin/sh isn't bash (e.g. dash), that fails immediately with set: Illegal option -o pipefail, so no SwiftPM build gets past the first build phase.

Two spots in generate-spm-xcodeproj.js:

  • shellScriptPhase hardcodes shellPath: '/bin/sh' for every PBXShellScriptBuildPhase it builds (Sync SPM Autolinking, Embed React Native Flavored Frameworks, plugin-contributed phases), while their bodies are bash-only. Now sets shellPath: '/bin/bash', and refreshes it on an already-injected project too.
  • The "Sync SPM Autolinking" scheme pre-action runs the same kind of script, but a scheme pre-action ignores a build phase's shellPath entirely — Xcode reads the shell from the ActionContent's own shellToInvoke attribute instead (default /bin/sh). Now sets shellToInvoke = "/bin/bash" on both scheme creation and when adding/refreshing the pre-action on an existing scheme.

Fixes #58359

Changelog:

[IOS] [FIXED] - SwiftPM: run generated build scripts under bash instead of /bin/sh, so they don't break on a host where /bin/sh isn't bash

Test Plan:

yarn test packages/react-native/scripts/spm — 838 passed, including new cases for the refreshed shellPath/shellToInvoke on a project injected before this fix, and a scheme injected before the attribute existed.

@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 6, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 6, 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.

SPM setup generates set -euo pipefail scripts but runs them with /bin/sh

1 participant