Skip to content

feat(expo): Warn when prebuilt native projects are missing Sentry config#5984

Merged
alwx merged 6 commits intomainfrom
alwx/expo-native-rebuild-warning
Apr 16, 2026
Merged

feat(expo): Warn when prebuilt native projects are missing Sentry config#5984
alwx merged 6 commits intomainfrom
alwx/expo-native-rebuild-warning

Conversation

@alwx
Copy link
Copy Markdown
Contributor

@alwx alwx commented Apr 13, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Adds a Metro startup check that warns Expo users when their prebuilt native projects (ios/ and android/) are missing Sentry configuration.

Fixes #4640

Users who add the Sentry Expo Plugin after already running expo prebuild get no indication that their native projects are stale. This leads to confusing issues where source maps upload and native crash reporting silently fail.

💚 How did you test it?

  • Verified build passes (yarn build)
  • Verified lint passes (oxlint)
  • TODO: Add unit tests

📝 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
  • No breaking changes

@alwx alwx self-assigned this Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 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).


  • feat(expo): Warn when prebuilt native projects are missing Sentry config by alwx in #5984

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 7139122

@alwx alwx force-pushed the alwx/expo-native-rebuild-warning branch from 5c0910a to 42d7ec5 Compare April 13, 2026 14:57
alwx added 2 commits April 16, 2026 13:45
When using the Sentry Expo Plugin with prebuilt native projects, users
need to run `npx expo prebuild --clean` to apply the native changes.
Without this step, source maps upload and native crash reporting won't
work correctly.

This adds a check in `getSentryExpoConfig()` that runs at Metro startup
and inspects existing ios/android directories for Sentry markers:
- iOS: looks for `sentry-xcode` or `Upload Debug Symbols to Sentry`
  in the pbxproj file
- Android: looks for `sentry.gradle` in app/build.gradle

The check only runs for Expo projects (detected via package.json) and
is fully wrapped in try/catch to never crash Metro startup.

Closes #4640
Tests cover:
- Skipping non-Expo projects (no package.json, no expo dependency)
- No warning when native dirs don't exist (managed workflow)
- No warning when Sentry is properly configured (iOS and Android)
- Warning when iOS, Android, or both are missing Sentry config
- Detection of expo in devDependencies
- Graceful error handling (fs throws, invalid JSON, no xcodeproj)
@alwx alwx force-pushed the alwx/expo-native-rebuild-warning branch from 42d7ec5 to 3278965 Compare April 16, 2026 11:47
@alwx alwx changed the title WIP: feat(expo): Warn when prebuilt native projects are missing Sentry config feat(expo): Warn when prebuilt native projects are missing Sentry config Apr 16, 2026
@alwx alwx marked this pull request as ready for review April 16, 2026 11:48
@alwx alwx marked this pull request as draft April 16, 2026 11:48
@alwx
Copy link
Copy Markdown
Contributor Author

alwx commented Apr 16, 2026

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e359044. Configure here.

@alwx alwx marked this pull request as ready for review April 16, 2026 13:42
@alwx
Copy link
Copy Markdown
Contributor Author

alwx commented Apr 16, 2026

@antonis this can be reviewed now

Comment thread packages/core/src/js/tools/sentryExpoNativeCheck.ts Outdated
The Expo native setup check only looked for 'sentry.gradle' in
android/app/build.gradle. When using the experimental Android Gradle
Plugin (enableAndroidGradlePlugin), the setup uses
'io.sentry.android.gradle' instead, causing a false positive warning.

Add detection for the 'io.sentry.android.gradle' plugin string so both
configuration paths are recognized.
Copy link
Copy Markdown
Contributor

@antonis antonis left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@alwx alwx merged commit 9278c8e into main Apr 16, 2026
48 of 57 checks passed
@alwx alwx deleted the alwx/expo-native-rebuild-warning branch April 16, 2026 15:02
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.

[Expo] Explicitly inform user about need of rebuilding the native project when using Sentry Expo Plugin

2 participants