Skip to content

fix(ios): Add SENTRY_PROJECT_ROOT env var for monorepo support#5961

Merged
antonis merged 2 commits intomainfrom
antonis/fix/monorepo-project-root
Apr 7, 2026
Merged

fix(ios): Add SENTRY_PROJECT_ROOT env var for monorepo support#5961
antonis merged 2 commits intomainfrom
antonis/fix/monorepo-project-root

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Apr 7, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Adds a SENTRY_PROJECT_ROOT environment variable to override the project root in sentry-xcode.sh and sentry-xcode-debug-files.sh.

Both scripts previously hardcoded the project root as PROJECT_DIR/.., which fails in monorepo setups (e.g., NX) where the ios/ directory is not directly under the React Native project root. Symlinked node_modules causes pwd to resolve to the monorepo root instead of the package directory.

The new env var uses the standard ${SENTRY_PROJECT_ROOT:-${PROJECT_DIR}/..} pattern, consistent with other overridable env vars in these scripts (NODE_BINARY, REACT_NATIVE_PATH, SENTRY_PROPERTIES, etc.).

When not set, behavior is identical to before.

💡 Motivation and Context

Fixes #2880 — reported in 2023, confirmed still relevant as of April 2025.

Monorepo users (NX, Turborepo) have been working around this by manually modifying their Xcode build phases. This provides an official, supported override.

💚 How did you test it?

  • Added tests verifying SENTRY_PROJECT_ROOT overrides sourcemap path resolution
  • Added test verifying sentry.options.json is found in custom project root
  • Added test verifying default fallback to PROJECT_DIR/.. when not set
  • All 32 tests in sentry-xcode-scripts.test.ts pass

📝 Checklist

🔮 Next steps

  • Docs PR to document SENTRY_PROJECT_ROOT on the manual setup page

Allow overriding the project root in Xcode build phase scripts via
SENTRY_PROJECT_ROOT for monorepo setups where the ios directory is not
directly under the React Native project root.

Fixes #2880

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

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): Add SENTRY_PROJECT_ROOT env var for monorepo support by antonis in #5961
  • fix(core): Lazy-load Metro internal modules to prevent Expo 55 import errors by lucas-zimerman in #5958
  • chore(deps): update Cocoa SDK to v9.9.0 by github-actions in #5956
  • chore(deps): update Maestro to v2.4.0 by github-actions in #5955
  • Feat: Fallback to stacktrace parsing by lucas-zimerman in #5946
  • fix(ci): Bump Node to 22 in size-analysis and testflight workflows by antonis in #5954
  • feat(playground): Open Sentry in desktop browser from Expo apps by antonis in #5947
  • chore(core): Bump sample app to React Native 0.84.1 by antonis in #5941
  • Size analysis for React Native SDK by alwx in #5949
  • chore(deps): bump lodash from 4.17.23 to 4.18.1 by dependabot in #5953
  • chore(deps): bump yauzl to ^3.2.1 by antonis in #5950
  • chore(deps): bump brace-expansion to ^2.0.3 by antonis in #5951
  • chore(deps): bump @xmldom/xmldom to fix XML injection by antonis in #5952

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request

Generated by 🚫 dangerJS against 89928b3

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sentry
Copy link
Copy Markdown

sentry bot commented Apr 7, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
Sentry RN io.sentry.reactnative.sample 8.7.0 (82) Release Install Build

@antonis antonis marked this pull request as ready for review April 7, 2026 10:39

### Fixes

- Add `SENTRY_PROJECT_ROOT` env var to override project root in Xcode build phase scripts for monorepo setups ([#5961](https://github.com/getsentry/sentry-react-native/pull/5961))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! We should also document this on sentry docs

Copy link
Copy Markdown
Contributor Author

@antonis antonis Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened a PR for this getsentry/sentry-docs#17269 and updated the PR description

@antonis antonis merged commit 2c735cc into main Apr 7, 2026
61 of 67 checks passed
@antonis antonis deleted the antonis/fix/monorepo-project-root branch April 7, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI incorrectly resolves path to the Metro config in a NX monorepo

2 participants