fix(ios): Add SENTRY_PROJECT_ROOT env var for monorepo support#5961
Merged
fix(ios): Add SENTRY_PROJECT_ROOT env var for monorepo support#5961
Conversation
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>
Contributor
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. |
Contributor
Open
6 tasks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sentry Build Distribution
|
|
|
||
| ### 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)) |
Collaborator
There was a problem hiding this comment.
LGTM! We should also document this on sentry docs
Contributor
Author
There was a problem hiding this comment.
Opened a PR for this getsentry/sentry-docs#17269 and updated the PR description
lucas-zimerman
approved these changes
Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📢 Type of change
📜 Description
Adds a
SENTRY_PROJECT_ROOTenvironment variable to override the project root insentry-xcode.shandsentry-xcode-debug-files.sh.Both scripts previously hardcoded the project root as
PROJECT_DIR/.., which fails in monorepo setups (e.g., NX) where theios/directory is not directly under the React Native project root. Symlinkednode_modulescausespwdto 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?
SENTRY_PROJECT_ROOToverrides sourcemap path resolutionsentry.options.jsonis found in custom project rootPROJECT_DIR/..when not setsentry-xcode-scripts.test.tspass📝 Checklist
sendDefaultPIIis enabled🔮 Next steps
SENTRY_PROJECT_ROOTon the manual setup page