Description
The SPM setup generates scripts that use set -euo pipefail but runs them under /bin/sh. On a machine where /bin/sh is not bash (e.g. dash), every iOS build fails before compiling anything:
SchemeScriptAction-6Thqas.sh: 2: set: Illegal option -o pipefail
** BUILD FAILED ** (xcodebuild 65)
Two places in scripts/spm/generate-spm-xcodeproj.js (line numbers on main):
- The injected
PBXShellScriptBuildPhases hardcode shellPath: '/bin/sh' (L322) while their script bodies start with set -euo pipefail (L462, L644). Fix: emit shellPath: '/bin/bash'.
- The
Sync SPM Autolinking scheme pre-action, which is the one that fails first. Xcode always runs scheme pre-actions under /bin/sh and there is no shellPath to set, so the script body itself has to be POSIX — or re-exec itself under bash.
Note that dropping -o pipefail is not sufficient for the pre-action: it also sources scripts/xcode/with-environment.sh, which uses source, another bashism dash does not have. Re-execing the pre-action under bash covers both.
Workaround for anyone hitting this: after spm add, rewrite shellPath = /bin/sh; to /bin/bash in project.pbxproj, and prepend [ -n "${BASH_VERSION-}" ] || [ ! -x /bin/bash ] || exec /bin/bash "$0" "$@" to the pre-action's scriptText in the .xcscheme.
Steps to reproduce
- Make
/bin/sh a non-bash POSIX shell (dash). Verify with /bin/sh -c 'set -o pipefail' → Illegal option -o pipefail.
- Create an app and run
npx react-native spm add on it.
xcodebuild -project App.xcodeproj -scheme App -configuration Debug -sdk iphonesimulator build
- The build dies in the
Sync SPM Autolinking scheme pre-action, before any source file is compiled.
React Native Version
0.87.0
Affected Platforms
Build - MacOS, Runtime - iOS
Output of npx @react-native-community/cli info
System:
OS: macOS 15.7.7
CPU: (11) arm64 Apple M3 Pro
Memory: 113.64 MB / 18.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 26.8.1
path: /opt/homebrew/bin/node
Yarn: Not Found
npm:
version: 11.19.0
path: /opt/homebrew/bin/npm
Watchman: Not Found
Managers:
CocoaPods: Not Found
SDKs:
iOS SDK:
Platforms:
- DriverKit 25.2
- iOS 26.2
- macOS 26.2
- tvOS 26.2
- visionOS 26.2
- watchOS 26.2
Android SDK: Not Found
IDEs:
Android Studio: 2026.1 AI-261.26222.65.2613.16025427
Xcode:
version: 26.3/17C529
path: /usr/bin/xcodebuild
Languages:
Java: Not Found
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 19.2.8
wanted: ^19.2.8
react-native:
installed: 0.87.0
wanted: 0.87.0
react-native-macos: Not Found
Stacktrace or Logs
SchemeScriptAction-6Thqas.sh: 2: set: Illegal option -o pipefail
** BUILD FAILED **
The following build commands failed:
Build scheme pre-action (in target 'App' from project 'App')
(1 failure)
Reproducer
No repository link: the trigger is the machine's /bin/sh, not project code. Any RN 0.87 project set up with npx react-native spm add reproduces it once /bin/sh is dash. The generator lines are cited above, and the failure is visible without a build via /bin/sh -c 'set -o pipefail'.
Description
The SPM setup generates scripts that use
set -euo pipefailbut runs them under/bin/sh. On a machine where/bin/shis not bash (e.g. dash), every iOS build fails before compiling anything:Two places in
scripts/spm/generate-spm-xcodeproj.js(line numbers onmain):PBXShellScriptBuildPhases hardcodeshellPath: '/bin/sh'(L322) while their script bodies start withset -euo pipefail(L462, L644). Fix: emitshellPath: '/bin/bash'.Sync SPM Autolinkingscheme pre-action, which is the one that fails first. Xcode always runs scheme pre-actions under/bin/shand there is noshellPathto set, so the script body itself has to be POSIX — or re-exec itself under bash.Note that dropping
-o pipefailis not sufficient for the pre-action: it also sourcesscripts/xcode/with-environment.sh, which usessource, another bashism dash does not have. Re-execing the pre-action under bash covers both.Workaround for anyone hitting this: after
spm add, rewriteshellPath = /bin/sh;to/bin/bashinproject.pbxproj, and prepend[ -n "${BASH_VERSION-}" ] || [ ! -x /bin/bash ] || exec /bin/bash "$0" "$@"to the pre-action'sscriptTextin the.xcscheme.Steps to reproduce
/bin/sha non-bash POSIX shell (dash). Verify with/bin/sh -c 'set -o pipefail'→Illegal option -o pipefail.npx react-native spm addon it.xcodebuild -project App.xcodeproj -scheme App -configuration Debug -sdk iphonesimulator buildSync SPM Autolinkingscheme pre-action, before any source file is compiled.React Native Version
0.87.0
Affected Platforms
Build - MacOS, Runtime - iOS
Output of
npx @react-native-community/cli infoStacktrace or Logs
Reproducer
No repository link: the trigger is the machine's
/bin/sh, not project code. Any RN 0.87 project set up withnpx react-native spm addreproduces it once/bin/shis dash. The generator lines are cited above, and the failure is visible without a build via/bin/sh -c 'set -o pipefail'.