SIGN IN SIGN UP

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

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 https://github.com/react/react-native/issues/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

Pull Request resolved: https://github.com/react/react-native/pull/58362

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.

Reviewed By: cortinico

Differential Revision: D119328611

Pulled By: cipolleschi

fbshipit-source-id: 2039a5c3c0224ca17d096f4837380b0977f4b539
L
Lazizbek Ergashev committed
25f48bd72fd47799fe81689d58f4cbd1b9ddd21c
Parent: f20f857
Committed by meta-codesync[bot] <215208954+meta-codesync[bot]@users.noreply.github.com> on 9/11/2026, 10:02:07 AM