Repository navigation
fix(ios): Find react-native-xcode.sh in hoisted monorepos - #7182
Conversation
When React Native's bundle phase runs sentry-xcode.sh without an argument, use $REACT_NATIVE_PATH/scripts/react-native-xcode.sh instead of the relative ../node_modules path, which doesn't exist when react-native is hoisted to the workspace root. Keep the relative path as the last fallback. Fixes #7175 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
PR risk: mediumFor commit Main concerns: dependencies customers inherit, reach, public contract. Rules that block low also fired:
This label is a hint for reviewers, not an approval. |
📲 Install BuildsAndroid
|
…there Fall back to ../node_modules/react-native when REACT_NATIVE_PATH is stale or unrelated, so setups that built before the fix keep building. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
📢 Type of change
📜 Description
When
sentry-xcode.shgets no argument, it now runs$REACT_NATIVE_PATH/scripts/react-native-xcode.shifREACT_NATIVE_PATHis set and the script exists there.REACT_NATIVE_PATHis the Xcode build setting that React Native's CocoaPods setup writes, from 0.69 on. Otherwise the script still falls back to../node_modules/react-native/scripts/react-native-xcode.sh, so a stale or unrelatedREACT_NATIVE_PATHcan't break a build that worked before. A script passed as an argument still takes precedence over both.💡 Motivation and Context
Fixes #7175
In a monorepo with hoisted
node_modules(app inapps/mobile,react-nativein the workspace root), the iOS Release build fails in "Bundle React Native code and images" with "No such file or directory".React Native's phase runs
$WITH_ENVIRONMENT $REACT_NATIVE_XCODE, andwith-environment.shruns only its$1. So whenREACT_NATIVE_XCODEpoints atsentry-xcode.sh, as the manual setup and both wizards set it up, the script gets no argument. It then fell back to../node_modules/react-native/…, relative toios/, which doesn't exist in a hoisted layout.REACT_NATIVE_PATHpoints at thereact-nativepackage wherever it's installed.Android isn't affected.
💚 How did you test it?
Real hoisted monorepo build (before/after)
I reproduced #7175 and checked the fix in a real iOS Release build.
Setup
nodeLinker: node-modules) with a bare React Native 0.88.1 app inapps/mobile.react-nativeand@sentry/react-native(packed from this branch) are installed only in the rootnode_modules;apps/mobile/node_modules/react-nativedoesn't exist.@sentry/wizard9.2.0 patches it. It runssentry-xcode.shthroughwith-environment.shwith no argument:pod installwrites theREACT_NATIVE_PATHbuild setting as${PODS_ROOT}/../../../../node_modules/react-native, the hoisted package.xcodebuild -configuration Release -sdk iphonesimulator(Xcode 27.2), with source maps uploaded to a Sentry test project. The only difference between the two runs issentry-xcode.sh.Result
sentry-xcode.shreact-native-xcode.shmain../node_modules/react-native/…, which doesn't exist$REACT_NATIVE_PATH/…→ rootnode_modules/react-nativeUploaded sourcemaps.main: build logWith the v4 Sentry CLI, this message replaces the "No such file or directory" quoted in #7175. The path is the same wrong one.
This PR: build log
The CLI also warned "No debug id found in the sourcemap". That's expected: the test app has no Sentry Metro config, and it's unrelated to this change.
The hoisted build was rerun with the final version, including the existence check, and still succeeds and uploads.
Not covered: pnpm workspaces (only Yarn was tested), and the wizard's separate debug-files upload phase (see Next steps).
Unit tests
packages/core/test/scripts/sentry-xcode-scripts.test.ts. They run the script with no argument in temp folders laid out like a hoisted monorepo and like a standard app:REACT_NATIVE_PATH, both with the upload disabled and as the--build-scriptpassed to the Sentry CLI. Both fail without the fix.REACT_NATIVE_PATH, falls back to../node_modules/react-native.REACT_NATIVE_PATHthat has noreact-native-xcode.sh, also falls back. This one fails if the check is only-n.REACT_NATIVE_PATH.sentry-xcode-scripts.test.tspasses (64/64) andyarn lintpasses.📝 Checklist
sendDefaultPIIis enabled.packages/core/etc/sentry-react-native.api.md) reviewed by another Mobile SDK team member or implemented according to the develop docs spec.🔮 Next steps
/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh. That path doesn't exist in a hoisted layout either. This was not covered by the A/B above.🤖 Generated with Claude Code