From 2ac64127d02c150e2ee22b59b4c521ef4c7f99ec Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Tue, 20 Oct 2026 15:48:01 +0200 Subject: [PATCH 1/2] refactor(ios): Use internal Cocoa serialization --- .../RNSentryCocoaTesterTests/RNSentryTests.m | 15 +++++---------- packages/core/ios/RNSentry+fetchNativeStack.m | 3 ++- packages/core/ios/RNSentry.mm | 4 ++-- packages/core/ios/RNSentryInternalWrapper.h | 5 +++++ packages/core/ios/RNSentryInternalWrapper.m | 7 +++++++ packages/core/ios/Swift/RNSentryInternal.swift | 10 ++++++++++ 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index a5aa18533a..b33cbdecc9 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -94,20 +94,16 @@ - (void)prepareNativeFrameMocksWithLocalSymbolication:(BOOL)debug OCMStub([sentryBinaryImageCacheMock imageByAddress:[@456 unsignedLongLongValue]]) .andReturn(sentryBinaryImageInfoMockTwo); - NSDictionary *serializedDebugImage = @{ - @"uuid" : @"mockuuid", - @"debug_id" : @"mockdebugid", - @"type" : @"macho", - @"image_addr" : @"0x000000000001b669", - }; - id sentryDebugImageMock = OCMClassMock([SentryDebugMeta class]); - OCMStub([sentryDebugImageMock serialize]).andReturn(serializedDebugImage); + SentryDebugMeta *sentryDebugImage = [[SentryDebugMeta alloc] init]; + sentryDebugImage.debugID = @"mockdebugid"; + sentryDebugImage.type = @"macho"; + sentryDebugImage.imageAddress = @"0x000000000001b669"; id sentryDebugImageProviderMock = OCMClassMock([SentryDebugImageProvider class]); OCMStub( [sentryDebugImageProviderMock getDebugImagesForImageAddressesFromCache:[NSSet setWithObject:@"0x000000000001b669"]]) - .andReturn(@[ sentryDebugImageMock ]); + .andReturn(@[ sentryDebugImage ]); OCMStub([sentryDependencyContainerMock debugImageProvider]) .andReturn(sentryDebugImageProviderMock); @@ -123,7 +119,6 @@ - (void)testFetchNativeStackFramesByInstructionsServerSymbolication NSDictionary *expected = @{ @"debugMetaImages" : @[ @{ - @"uuid" : @"mockuuid", @"debug_id" : @"mockdebugid", @"type" : @"macho", @"image_addr" : @"0x000000000001b669", diff --git a/packages/core/ios/RNSentry+fetchNativeStack.m b/packages/core/ios/RNSentry+fetchNativeStack.m index 6e67f563df..cede3bf30e 100644 --- a/packages/core/ios/RNSentry+fetchNativeStack.m +++ b/packages/core/ios/RNSentry+fetchNativeStack.m @@ -2,6 +2,7 @@ #import "RNSentryBreadcrumb.h" #import "RNSentryHexFormatter.h" #import "RNSentryId.h" +#import "RNSentrySwiftBridge.h" #import "SentrySDKWrapper.h" @import Sentry; @@ -75,7 +76,7 @@ - (NSDictionary *)fetchNativeStackFramesBy:(NSArray *)instructionsAd getDebugImagesForImageAddressesFromCache:imagesAddrToRetrieveDebugMetaImages]; for (SentryDebugMeta *debugImage in debugMetaImages) { - [serializedDebugMetaImages addObject:[debugImage serialize]]; + [serializedDebugMetaImages addObject:[RNSentryInternal serializeDebugMeta:debugImage]]; } return @{ diff --git a/packages/core/ios/RNSentry.mm b/packages/core/ios/RNSentry.mm index 56398156d9..0e11ece5ae 100644 --- a/packages/core/ios/RNSentry.mm +++ b/packages/core/ios/RNSentry.mm @@ -444,7 +444,7 @@ - (void)handleShakeDetected [SentrySDKWrapper configureScope:^(SentryScope *_Nonnull scope) { // Serialize to get contexts dictionary - NSDictionary *serializedScope = [scope serialize]; + NSDictionary *serializedScope = [RNSentryInternalWrapper serializeScope:scope]; NSDictionary *allContexts = serializedScope[@"context"]; // It's singular here, annoyingly NSMutableDictionary *contexts = [NSMutableDictionary new]; @@ -496,7 +496,7 @@ - (void)handleShakeDetected } __block NSMutableDictionary *serializedScope; [SentrySDKWrapper configureScope:^(SentryScope *_Nonnull scope) { - serializedScope = [[scope serialize] mutableCopy]; + serializedScope = [[RNSentryInternalWrapper serializeScope:scope] mutableCopy]; NSDictionary *user = [serializedScope valueForKey:@"user"]; if (user == nil) { diff --git a/packages/core/ios/RNSentryInternalWrapper.h b/packages/core/ios/RNSentryInternalWrapper.h index a05121c3d8..9bb94c3c82 100644 --- a/packages/core/ios/RNSentryInternalWrapper.h +++ b/packages/core/ios/RNSentryInternalWrapper.h @@ -2,6 +2,7 @@ @class SentryEnvelope; @class SentryId; +@class SentryScope; NS_ASSUME_NONNULL_BEGIN @@ -40,6 +41,10 @@ NS_ASSUME_NONNULL_BEGIN @property (class, readonly) BOOL isFramesTrackingRunning; +// MARK: - Serialization + ++ (NSDictionary *)serializeScope:(SentryScope *)scope; + // MARK: - Envelopes + (nullable SentryEnvelope *)envelopeFromData:(nullable NSData *)data; diff --git a/packages/core/ios/RNSentryInternalWrapper.m b/packages/core/ios/RNSentryInternalWrapper.m index 0ffde0639d..d1b40c0714 100644 --- a/packages/core/ios/RNSentryInternalWrapper.m +++ b/packages/core/ios/RNSentryInternalWrapper.m @@ -44,6 +44,13 @@ + (BOOL)isFramesTrackingRunning return RNSentryInternal.isFramesTrackingRunning; } +// MARK: - Serialization + ++ (NSDictionary *)serializeScope:(SentryScope *)scope +{ + return [RNSentryInternal serializeScope:scope]; +} + // MARK: - Envelopes + (SentryEnvelope *)envelopeFromData:(NSData *)data diff --git a/packages/core/ios/Swift/RNSentryInternal.swift b/packages/core/ios/Swift/RNSentryInternal.swift index 51a0fc4f4d..f8a4750321 100644 --- a/packages/core/ios/Swift/RNSentryInternal.swift +++ b/packages/core/ios/Swift/RNSentryInternal.swift @@ -95,6 +95,16 @@ import Foundation // stub on macOS/watchOS. #endif + // MARK: - Serialization + + @_spi(Private) @objc public static func serializeScope(_ scope: Scope) -> [String: Any] { + SentrySDK.internal.serializer.serialize(scope: scope) + } + + @_spi(Private) @objc public static func serializeDebugMeta(_ debugMeta: DebugMeta) -> [String: Any] { + SentrySDK.internal.serializer.serialize(debugMeta: debugMeta) + } + // MARK: - Envelope // Accepts `Data?` (nil-safe) rather than `Data` so the ObjC bridge boundary From 2b64ff540619da5c76b7007f0ad0bc48288b08fa Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 22 Oct 2026 07:43:34 +0000 Subject: [PATCH 2/2] chore: update scripts/update-cocoa.sh to 9.31.0 --- CHANGELOG.md | 6 ++++++ packages/core/Package.swift | 4 ++-- packages/core/RNSentry.podspec | 2 +- packages/core/scripts/sentry_utils.rb | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d53102b87..3670bdc7f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,12 @@ - Stop wrapping the SDK's own `RNSentry` module in `turboModuleContextIntegration` by default. Each wrapped call wrote to the native scope several times, which added CPU time to every SDK call on iOS ([#6921](https://github.com/getsentry/sentry-react-native/pull/6921)) - To wrap `RNSentry` again, add `{ name: 'RNSentry' }` to the `modules` option. +### Dependencies + +- Bump Cocoa SDK from v9.30.2 to v9.31.0 ([#6925](https://github.com/getsentry/sentry-react-native/pull/6925)) + - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#9310) + - [diff](https://github.com/getsentry/sentry-cocoa/compare/9.30.2...9.31.0) + ## 8.31.0 ### Features diff --git a/packages/core/Package.swift b/packages/core/Package.swift index ecc04e16e7..354c139a95 100644 --- a/packages/core/Package.swift +++ b/packages/core/Package.swift @@ -77,8 +77,8 @@ let reactNativeHeaderProducts: [Target.Dependency] = [ // `scripts/update-cocoa.sh` keeps the version and the checksum in step with // `sentry_cocoa_version` in RNSentry.podspec. The checksum is the SHA256 of the // archive, which is what both `pod install` and SwiftPM verify. -let sentryCocoaVersion = "9.30.2" -let sentryCocoaChecksum = "593897dbdee24febeef45208b13960a4b389c5dbd25f64b1b3cb94c30291ed55" +let sentryCocoaVersion = "9.31.0" +let sentryCocoaChecksum = "86dde13e6145ea3049ee2eb0b07ccb66e137a4d3af0d0dfe0b9d895f80b43237" let sentryCocoa: Target.Dependency = "Sentry" diff --git a/packages/core/RNSentry.podspec b/packages/core/RNSentry.podspec index 09684a389e..7b32b1c352 100644 --- a/packages/core/RNSentry.podspec +++ b/packages/core/RNSentry.podspec @@ -68,7 +68,7 @@ Pod::Spec.new do |s| 'DEFINES_MODULE' => 'YES' } - sentry_cocoa_version = '9.30.2' + sentry_cocoa_version = '9.31.0' # Consume sentry-cocoa as a prebuilt `Sentry.xcframework` by default. # diff --git a/packages/core/scripts/sentry_utils.rb b/packages/core/scripts/sentry_utils.rb index 22fc07aa4a..3d42506e89 100644 --- a/packages/core/scripts/sentry_utils.rb +++ b/packages/core/scripts/sentry_utils.rb @@ -60,8 +60,8 @@ def is_new_hermes_runtime(rn_version) # `Sentry` module. `Sentry-Dynamic.xcframework` would ship the same # `Sentry.framework` inside but under a mismatched enclosing name, so # CocoaPods generates `-framework Sentry-Dynamic` and fails at link. - '9.30.2' => { - 'Sentry' => '593897dbdee24febeef45208b13960a4b389c5dbd25f64b1b3cb94c30291ed55', + '9.31.0' => { + 'Sentry' => '86dde13e6145ea3049ee2eb0b07ccb66e137a4d3af0d0dfe0b9d895f80b43237', }, }.freeze