From cc7f9fd89f004f9bc007cb8bac1afff294d8a289 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Tue, 1 Sep 2026 12:52:24 +0200 Subject: [PATCH 1/2] ref(ios): Remove deprecated private SDK API usage Route remaining internal access through SentrySDK.internal and the React Native Swift bridge, including visionOS, tests, and samples. --- CHANGELOG.md | 4 +-- .../RNSentryReplayOptionsTests.swift | 4 +-- .../RNSentryCocoaTesterTests/RNSentryTests.m | 8 +++--- packages/core/ios/AGENTS.md | 4 +-- packages/core/ios/RNSentryInternal.swift | 25 ++----------------- .../ios/SentryNativeInitializer.m | 5 ++-- .../sentryreactnativesample/AppDelegate.mm | 1 - 7 files changed, 15 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6da53a3ce2..16e63dafe1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,7 +55,7 @@ ### Changes -- Migrate iOS internals from the deprecated `PrivateSentrySDKOnly` SPI to `SentrySDK.internal` ([#6541](https://github.com/getsentry/sentry-react-native/pull/6541)) +- Migrate the remaining iOS internals from the deprecated Objective-C SPI to `SentrySDK.internal` ([#6541](https://github.com/getsentry/sentry-react-native/pull/6541)) Re-lands [#6380](https://github.com/getsentry/sentry-react-native/pull/6380), reverted in 8.20.0 by [#6491](https://github.com/getsentry/sentry-react-native/pull/6491) because it broke iOS screenshot capture. The underlying sentry-cocoa bug is fixed in 9.24.0. @@ -227,7 +227,7 @@ ### Internal -- Migrate iOS code from the deprecated `PrivateSentrySDKOnly` SPI (and `SentrySwizzle.h` macro) to the new `SentrySDK.internal` Swift API exposed by sentry-cocoa 9.19.0, via a thin in-pod ObjC↔Swift bridge ([#6380](https://github.com/getsentry/sentry-react-native/pull/6380)) +- Migrate iOS code from the deprecated Objective-C SPI (and `SentrySwizzle.h` macro) to the new `SentrySDK.internal` Swift API exposed by sentry-cocoa 9.19.0, via a thin in-pod ObjC↔Swift bridge ([#6380](https://github.com/getsentry/sentry-react-native/pull/6380)) ### Dependencies diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift index da7f1ccad1..054b7a13a2 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift @@ -64,7 +64,7 @@ final class RNSentryReplayOptions: XCTestCase { ] as NSDictionary).mutableCopy() as! NSMutableDictionary RNSentryReplay.updateOptions(optionsDict) - let actualOptions = try! PrivateSentrySDKOnly.options(with: optionsDict as! [String: Any]) + let actualOptions = try! SentrySDK.internal.options(fromDictionary: optionsDict as! [String: Any]) XCTAssertEqual(actualOptions.sessionReplay.networkDetailAllowUrls.count, 1) XCTAssertEqual(actualOptions.sessionReplay.networkDetailDenyUrls.count, 1) @@ -84,7 +84,7 @@ final class RNSentryReplayOptions: XCTestCase { ] as NSDictionary).mutableCopy() as! NSMutableDictionary RNSentryReplay.updateOptions(optionsDict) - let actualOptions = try! PrivateSentrySDKOnly.options(with: optionsDict as! [String: Any]) + let actualOptions = try! SentrySDK.internal.options(fromDictionary: optionsDict as! [String: Any]) XCTAssertEqual(actualOptions.sessionReplay.networkDetailAllowUrls.count, 1) XCTAssertFalse(actualOptions.sessionReplay.networkCaptureBodies) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index 37f520b061..a5aa18533a 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -5,10 +5,10 @@ #import "SentrySDKWrapper.h" #import #import -#import #import #import #import +@import RNSentry.Swift; @import Sentry; @interface RNSentryInitNativeSdkTests : XCTestCase @@ -283,7 +283,7 @@ - (void)testStartWithDictionaryRemovesPerformanceProperties } ; [RNSentryStart startWithOptions:mockedReactNativeDictionary error:&error]; -SentryOptions *actualOptions = PrivateSentrySDKOnly.options; +SentryOptions *actualOptions = RNSentryInternal.options; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); XCTAssertNotNil( @@ -303,7 +303,7 @@ - (void)testStartCaptureFailedRequestsIsDisabled @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", }; [RNSentryStart startWithOptions:mockedReactNativeDictionary error:&error]; - SentryOptions *actualOptions = PrivateSentrySDKOnly.options; + SentryOptions *actualOptions = RNSentryInternal.options; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); @@ -638,7 +638,7 @@ - (void)testStartWithDictionaryInstallsConfigureProfilingFromExperimentsProfilin }, }; [RNSentryStart startWithOptions:mockedReactNativeDictionary error:&error]; - SentryOptions *actualOptions = PrivateSentrySDKOnly.options; + SentryOptions *actualOptions = RNSentryInternal.options; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); diff --git a/packages/core/ios/AGENTS.md b/packages/core/ios/AGENTS.md index 04edda1bad..99498c23db 100644 --- a/packages/core/ios/AGENTS.md +++ b/packages/core/ios/AGENTS.md @@ -66,5 +66,5 @@ through a Swift bridge in `RNSentryInternal.swift`. The bridge imports Sentry with `@_spi(Private)` because several sub-APIs (`performance.currentScreenFrames`, `replay.configure`, `envelope.{store,capture,deserialize}`) are SPI-gated. `.m`/`.mm` callers import the auto-generated `RNSentry-Swift.h` and route -through `[RNSentryInternal …]` instead of touching `PrivateSentrySDKOnly` -(deprecated since cocoa 9.19.0 and slated for removal in the next major). +through `[RNSentryInternal …]` instead of accessing sentry-cocoa internals +directly. diff --git a/packages/core/ios/RNSentryInternal.swift b/packages/core/ios/RNSentryInternal.swift index 6fdfd4b810..7667c1372e 100644 --- a/packages/core/ios/RNSentryInternal.swift +++ b/packages/core/ios/RNSentryInternal.swift @@ -100,7 +100,7 @@ import Foundation // Accepts `Data?` (nil-safe) rather than `Data` so the ObjC bridge boundary // doesn't force-unwrap a nil `NSData*` from a failed base64 decode — that // would crash before we ever get a chance to check the result. Matches the - // nil-tolerant behaviour of the deprecated `PrivateSentrySDKOnly.envelopeWithData:`. + // nil-tolerant behavior of the previous Objective-C envelope API. @_spi(Private) @objc public static func envelope(fromData data: Data?) -> SentryEnvelope? { guard let data = data else { return nil } return SentrySDK.internal.envelope.deserialize(from: data) @@ -116,16 +116,7 @@ import Foundation // MARK: - Screenshot / view hierarchy / screen - // sentry-cocoa's `SentryInternalScreen/Screenshot/ViewHierarchyApi` are all - // gated to `(os(iOS) || os(tvOS)) && !SENTRY_NO_UI_FRAMEWORK`. On visionOS - // the new hybrid-SDK surface is intentionally absent, but the same - // functionality still lives on `PrivateSentrySDKOnly` (gated by - // `SENTRY_HAS_UIKIT`, which covers visionOS). Route the visionOS bridge - // through the deprecated SPI so we preserve pre-migration behaviour and - // keep this PR non-breaking. Remove the fallback once sentry-cocoa - // exposes these APIs on visionOS in the hybrid surface — or once cocoa - // drops `PrivateSentrySDKOnly` in a future major and forces our hand. - #if os(iOS) || os(tvOS) + #if os(iOS) || os(tvOS) || os(visionOS) @_spi(Private) @objc public static var captureScreenshots: [Data]? { SentrySDK.internal.screenshot.capture() } @@ -137,18 +128,6 @@ import Foundation @_spi(Private) @objc public static func setCurrentScreen(_ screenName: String?) { SentrySDK.internal.screen.setCurrent(screenName) } - #elseif os(visionOS) - @_spi(Private) @objc public static var captureScreenshots: [Data]? { - PrivateSentrySDKOnly.captureScreenshots() - } - - @_spi(Private) @objc public static var captureViewHierarchy: Data? { - PrivateSentrySDKOnly.captureViewHierarchy() - } - - @_spi(Private) @objc public static func setCurrentScreen(_ screenName: String?) { - PrivateSentrySDKOnly.setCurrentScreen(screenName) - } #else @_spi(Private) @objc public static var captureScreenshots: [Data]? { nil } @_spi(Private) @objc public static var captureViewHierarchy: Data? { nil } diff --git a/samples/react-native/ios/SentryNativeInitializer.m b/samples/react-native/ios/SentryNativeInitializer.m index 3a68b07574..4d2a9dd786 100644 --- a/samples/react-native/ios/SentryNativeInitializer.m +++ b/samples/react-native/ios/SentryNativeInitializer.m @@ -1,4 +1,5 @@ #import "SentryNativeInitializer.h" +@import RNSentry.Swift; @import Sentry; @implementation SentryNativeInitializer @@ -27,9 +28,9 @@ + (void)initializeSentry // Enable the App start and Frames tracking measurements // If this is disabled the app start and frames tracking // won't be passed from native to JS transactions - PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = true; + RNSentryInternal.appStartMeasurementHybridSDKMode = true; #if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST - PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode = true; + RNSentryInternal.framesTrackingMeasurementHybridSDKMode = true; #endif }]; } diff --git a/samples/react-native/ios/sentryreactnativesample/AppDelegate.mm b/samples/react-native/ios/sentryreactnativesample/AppDelegate.mm index 616456ca75..b0fdf8ea61 100644 --- a/samples/react-native/ios/sentryreactnativesample/AppDelegate.mm +++ b/samples/react-native/ios/sentryreactnativesample/AppDelegate.mm @@ -15,7 +15,6 @@ #import "SentryNativeInitializer.h" #import -#import #import @interface AppDelegate () { From d9edb88f7311875372bfa8be1d13c7f2d4664d30 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Tue, 1 Sep 2026 12:56:06 +0200 Subject: [PATCH 2/2] docs: Restore historical changelog entries --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16e63dafe1..6da53a3ce2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,7 +55,7 @@ ### Changes -- Migrate the remaining iOS internals from the deprecated Objective-C SPI to `SentrySDK.internal` ([#6541](https://github.com/getsentry/sentry-react-native/pull/6541)) +- Migrate iOS internals from the deprecated `PrivateSentrySDKOnly` SPI to `SentrySDK.internal` ([#6541](https://github.com/getsentry/sentry-react-native/pull/6541)) Re-lands [#6380](https://github.com/getsentry/sentry-react-native/pull/6380), reverted in 8.20.0 by [#6491](https://github.com/getsentry/sentry-react-native/pull/6491) because it broke iOS screenshot capture. The underlying sentry-cocoa bug is fixed in 9.24.0. @@ -227,7 +227,7 @@ ### Internal -- Migrate iOS code from the deprecated Objective-C SPI (and `SentrySwizzle.h` macro) to the new `SentrySDK.internal` Swift API exposed by sentry-cocoa 9.19.0, via a thin in-pod ObjC↔Swift bridge ([#6380](https://github.com/getsentry/sentry-react-native/pull/6380)) +- Migrate iOS code from the deprecated `PrivateSentrySDKOnly` SPI (and `SentrySwizzle.h` macro) to the new `SentrySDK.internal` Swift API exposed by sentry-cocoa 9.19.0, via a thin in-pod ObjC↔Swift bridge ([#6380](https://github.com/getsentry/sentry-react-native/pull/6380)) ### Dependencies