Skip to content

fix(ios): Find react-native-xcode.sh in hoisted monorepos - #7182

Merged
antonis merged 5 commits into
mainfrom
fix/sentry-xcode-hoisted-monorepo
Dec 4, 2026
Merged

antonis merged 5 commits into
mainfrom
fix/sentry-xcode-hoisted-monorepo

Conversation

@antonis

@antonis antonis commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

When sentry-xcode.sh gets no argument, it now runs $REACT_NATIVE_PATH/scripts/react-native-xcode.sh if REACT_NATIVE_PATH is set and the script exists there. REACT_NATIVE_PATH is 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 unrelated REACT_NATIVE_PATH can'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 in apps/mobile, react-native in 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, and with-environment.sh runs only its $1. So when REACT_NATIVE_XCODE points at sentry-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 to ios/, which doesn't exist in a hoisted layout. REACT_NATIVE_PATH points at the react-native package 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

  1. Yarn 4 workspace (nodeLinker: node-modules) with a bare React Native 0.88.1 app in apps/mobile. react-native and @sentry/react-native (packed from this branch) are installed only in the root node_modules; apps/mobile/node_modules/react-native doesn't exist.
  2. The "Bundle React Native code and images" phase was patched the way @sentry/wizard 9.2.0 patches it. It runs sentry-xcode.sh through with-environment.sh with no argument:
    WITH_ENVIRONMENT="$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
    SENTRY_XCODE="$REACT_NATIVE_PATH/../@sentry/react-native/scripts/sentry-xcode.sh"
    /bin/sh -c "\"$WITH_ENVIRONMENT\" \"$SENTRY_XCODE\""
  3. pod install writes the REACT_NATIVE_PATH build setting as ${PODS_ROOT}/../../../../node_modules/react-native, the hoisted package.
  4. xcodebuild -configuration Release -sdk iphonesimulator (Xcode 27.2), with source maps uploaded to a Sentry test project. The only difference between the two runs is sentry-xcode.sh.

Result

sentry-xcode.sh Resolved react-native-xcode.sh Build Source maps
main ../node_modules/react-native/…, which doesn't exist ❌ BUILD FAILED not uploaded
this PR $REACT_NATIVE_PATH/… → root node_modules/react-native ✅ BUILD SUCCEEDED Uploaded sourcemaps.
main: build log
+ REACT_NATIVE_XCODE=../node_modules/react-native/scripts/react-native-xcode.sh
error: sentry-cli - Error: React Native build script not found: <workspace>/apps/mobile/node_modules/react-native/scripts/react-native-xcode.sh
** BUILD FAILED **

With 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
+ REACT_NATIVE_XCODE=<workspace>/apps/mobile/ios/Pods/../../../../node_modules/react-native/scripts/react-native-xcode.sh
output: sentry-cli - LOG:Done writing bundle output
output: sentry-cli - LOG:Done writing sourcemap output
output: sentry-cli - [react-native.xcode] ℹ Using Hermes bundle and combined source map.
output: sentry-cli - [react-native.xcode] ℹ Processing React Native sourcemaps for Sentry upload.
output: sentry-cli - │ Bundle        │ …/Release-iphonesimulator/MobileApp.app/main.jsbundle │
output: sentry-cli - │ Release       │ org.reactjs.native.example.MobileApp@1.0+1            │
output: sentry-cli - │ Distributions │ 1                                                     │
output: sentry-cli - Uploaded sourcemaps.
** BUILD SUCCEEDED **

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

  • Added 5 tests to 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:
    • Runs the React Native script from REACT_NATIVE_PATH, both with the upload disabled and as the --build-script passed to the Sentry CLI. Both fail without the fix.
    • Without REACT_NATIVE_PATH, falls back to ../node_modules/react-native.
    • With a REACT_NATIVE_PATH that has no react-native-xcode.sh, also falls back. This one fails if the check is only -n.
    • A script passed as an argument takes precedence over REACT_NATIVE_PATH.
  • sentry-xcode-scripts.test.ts passes (64/64) and yarn lint passes.

📝 Checklist

  • I added tests to verify changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing.
  • Public API changes (packages/core/etc/sentry-react-native.api.md) reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

  • Separate from this PR: the wizard's "Upload Debug Symbols to Sentry" phase runs /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

antonis and others added 2 commits December 4, 2026 12:15
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>
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

⚪ None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • fix(ios): Find react-native-xcode.sh in hoisted monorepos by antonis with claude in #7182
  • fix(core): Put native linked errors before the original exception by lazerg and antonis in #7179
  • chore(deps): update CLI to v4.0.1 by github-actions in #7180
  • feat(core): Use the Sentry CLI v4, with a v3 fallback by BYK and antonis with sentry-junior in #7177
  • chore(deps): update Wizard to v9.2.0 by github-actions in #7176

🤖 This preview updates automatically when you update the PR.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

🚨 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:

  • packages/core/scripts/sentry-xcode.sh

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 0aa270e.

Main concerns: dependencies customers inherit, reach, public contract.

Rules that block low also fired:

  • R6: build or release configuration changed: packages/core/scripts/sentry-xcode.sh

This label is a hint for reviewers, not an approval.

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Dec 4, 2026
@sentry

sentry Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.38.0 (118) Release

⚙️ sentry-react-native Build Distribution Settings

…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>
@github-actions github-actions Bot removed the risk: medium PR risk score: medium label Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

🚨 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:

  • packages/core/scripts/sentry-xcode.sh

@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 4, 2026
@github-actions github-actions Bot removed the risk: medium PR risk score: medium label Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

🚨 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:

  • packages/core/scripts/sentry-xcode.sh

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 4, 2026
@antonis
antonis marked this pull request as ready for review December 4, 2026 12:36
@github-actions github-actions Bot removed the risk: medium PR risk score: medium label Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

🚨 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:

  • packages/core/scripts/sentry-xcode.sh

@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 4, 2026
@antonis
antonis merged commit 39d7932 into main Dec 4, 2026
87 of 92 checks passed
@antonis
antonis deleted the fix/sentry-xcode-hoisted-monorepo branch December 4, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS Release build fails in hoisted monorepos: sentry-xcode.sh falls back to ../node_modules/react-native

2 participants