fix(ios): Re-land SentrySDK.internal migration, bump Cocoa SDK to 9.24.0 - #6541
Draft
alwx wants to merge 2 commits into
Draft
fix(ios): Re-land SentrySDK.internal migration, bump Cocoa SDK to 9.24.0#6541alwx wants to merge 2 commits into
alwx wants to merge 2 commits into
Conversation
Reapplies #6380 (reverted in 8.20.0 by #6491) now that the underlying sentry-cocoa bug is fixed. #6380 migrated iOS code from the deprecated PrivateSentrySDKOnly SPI to the SentrySDK.internal Swift API. It shipped in 8.19.0 and broke every iOS screenshot (Feedback Widget screenshot, attachScreenshot, Sentry.captureScreenshot) — #6497. Root cause was in sentry-cocoa: constructing SentryInternalApi eagerly reads SentryDependencyContainer.screenshotSource, a lazy var whose builder returns nil while startOptions is unset. Being lazy, that nil was cached for the process lifetime, and RN reads SentrySDK.internal before SentrySDK.start (from RNSentryStart, and from JS integrations calling fetchNativeAppStart / fetchNativeSdkInfo during init). getsentry/sentry-cocoa#8578 makes screenshotSource a computed property so the builder re-runs until startOptions is available; it shipped in 9.24.0, which this bumps to. Adds RNSentryScreenshotSourceTests as a regression guard: it reads SentrySDK.internal before starting the SDK and asserts screenshot capture still works. Verified to fail against 9.19.1 and pass against 9.24.0. Re-landing also restores the two improvements the revert removed: the fetchViewHierarchy nil-guard (returns null instead of a zero-byte attachment on capture failure) and the RNSentryTimeToDisplay extern linkage. Fixes #6507.
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
| #import "RNSentryHexFormatter.h" | ||
| #import "RNSentryId.h" | ||
| #import <Sentry/PrivateSentrySDKOnly.h> | ||
| @import Sentry; |
Contributor
There was a problem hiding this comment.
RNSentry+fetchNativeStack.m still calls SentrySDKInternal after removing its private header import
This file drops #import <Sentry/PrivateSentrySDKOnly.h> but still uses [SentrySDKInternal.options debug] at line 14, while every other production file migrated to RNSentryInternal. If SentrySDKInternal is no longer exported by Cocoa SDK 9.24.0, options resolves to nil and local symbolication is silently disabled.
Evidence
- The hunk removes
#import <Sentry/PrivateSentrySDKOnly.h>(line 5), the header that previously declaredSentrySDKInternal. [SentrySDKInternal.options debug]on line 14 was never updated to the newRNSentryInternalbridge.SentrySDKInternalis only forward-declared inRNSentry.hwith no@implementationin this repo; the Cocoa SDK binary must supply it.- Every other production
.m/.mmfile (e.g.RNSentryStart.m,SentrySDKWrapper.m) was migrated to[RNSentryInternal options]and imports the generated Swift header. - Only the test suite still imports
PrivateSentrySDKOnly.hto accessSentrySDKInternal, confirming it is a private API that the migration intends to leave behind.
Identified by Warden · code-review · QZL-8NM
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
Re-lands #6380 (the
PrivateSentrySDKOnly→SentrySDK.internalmigration), which shipped in 8.19.0 and was reverted in 8.20.0 by #6491, now that the underlying sentry-cocoa bug is fixed.Three parts:
scripts/update-cocoa.sh set-version 9.24.0).packages/core/iossince the revert were the two release commits.RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryScreenshotSourceTests.swift.Re-landing also restores the two improvements #6491 removed along with the migration: the
fetchViewHierarchynil-guard (returnsnullinstead of a zero-byte attachment when capture fails) and theRNSentryTimeToDisplayexternlinkage change.Important
This re-introduces the RN < 0.75 requirement from 8.19.0: on React Native versions where
React-hermes(or another RN pod) is not modularized by default (e.g. RN 0.71), users must adduse_modular_headers!to theirios/Podfile. CocoaPods refuses to integrate a Swift pod against non-modular ObjC dependencies, andRNSentryInternal.swiftmakesRNSentrya Swift pod. Called out in the CHANGELOG.💡 Motivation and Context
Fixes #6507.
#6380 broke all iOS screenshot capture — Feedback Widget screenshot,
attachScreenshot, andSentry.captureScreenshot()(#6497).Root cause was in sentry-cocoa, not in RN: constructing
SentryInternalApieagerly readsSentryDependencyContainer.screenshotSource, which was alazy varwhose builder returnsnilwhilestartOptionsis unset. Beinglazy, thatnilwas cached for the process lifetime. RN readsSentrySDK.internalbeforeSentrySDK.start— fromRNSentryStartitself, and from JS integrations calling native methods likefetchNativeAppStart/fetchNativeSdkInfoduring init — so the source was reliably poisoned. A targeted RN-side fix wasn't possible because JS controls the timing of those calls, hence the full revert.getsentry/sentry-cocoa#8578 makes
screenshotSourcea computed property sogetOptionalLazyVarre-runs the builder untilstartOptionsis available, and only then caches. It shipped in 9.24.0.I also confirmed:
SentrySDK.internalis a computed property that builds a freshSentryInternalApiper access, so the eager read inSentryInternalScreenshotApi.initis harmless oncescreenshotSourcerebuilds.viewHierarchyProvideris still alazy var, but its builder never touchesstartOptions, so it cannot be poisoned the same way.Sources/Swift/HybridSDK/between 9.19.1 and 9.24.0 — the only diffs are@_implementationOnly import→internal import. Every symbolRNSentryInternal.swiftbridges still exists with the same signature.enableReplayNetworkDetailsCapturingwas removed in 9.22.0 but RN never set it.💚 How did you test it?
New regression test (
RNSentryScreenshotSourceTests): readsSentrySDK.internalbeforeSentrySDK.start, then starts viaRNSentryStart.startwithattachScreenshotand assertsSentrySDK.internal.screenshot.capture()is non-nil. Verified it is not vacuous:XCTAssertNotNil failed— reproduces #6497Full native suite —
RNSentryCocoaTester, Release config, iPhone simulator, Xcode 26.1: 163 tests, 0 failures.Linters:
swiftlint --strictclean (13 files, 0 violations),clang-formatclean.No JS/TS source changed, so no api-report or JS test impact.
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Needs the
ready-to-mergelabel before merging so the native / E2E / sample-app workflows run — the iOSfeedbackE2E flow is what surfaced #6497 in the first place and should be confirmed green.Two pre-existing problems found while writing the regression test, both unrelated to this change and left for follow-up issues:
RNSentryStartTests.swiftandRNSentryStartFromFileTests.swiftare not in the Xcode test target. They were dropped fromproject.pbxprojaround the v7 merge (6ab6b160) and have not compiled or run since. They no longer build (Options.enableTracingwas removed in cocoa v9), and once that's fixed every test in them crashes — see below. I intentionally did not re-enable them here; that's why the new regression test lives in its own file.RNSentrySDK.startproceeds withoptions == nilwhensentry.options.jsonis absent or unparseable (packages/core/ios/RNSentrySDK.mL64-72). The@{}fallback also fails validation ("Invalid DSN URL") and returnsnil, but the code carries on intoupdateWithReactDefaults:/configureOptions(...)/startWithOptions:. Identical before and after refactor(ios): Migrate from PrivateSentrySDKOnly to SentrySDK.internal #6380 — bothPrivateSentrySDKOnly.optionsWithDictionary:didFailWithError:andSentrySDK.internal.options(fromDictionary:)funnel into the sameSentryOptionsInternal initWithDict:, which returnsnilon failure. From ObjC it silently no-ops; from Swift (options.dsn = …on an implicitly-unwrappedSentryOptions!) it segfaults.