From 686b6f851a8a74dcc48e2a903554a35f1fb8152e Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Mon, 8 Sep 2025 15:27:39 -0300 Subject: [PATCH 1/6] fix: Fixes SentryScreenFrames use after being converted to Swift --- packages/core/ios/RNSentry.mm | 16 +++------ packages/core/ios/SentryScreenFramesWrapper.h | 10 ++++++ packages/core/ios/SentryScreenFramesWrapper.m | 35 +++++++++++++++++++ 3 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 packages/core/ios/SentryScreenFramesWrapper.h create mode 100644 packages/core/ios/SentryScreenFramesWrapper.m diff --git a/packages/core/ios/RNSentry.mm b/packages/core/ios/RNSentry.mm index 8d65efc5b3..eaf743bfff 100644 --- a/packages/core/ios/RNSentry.mm +++ b/packages/core/ios/RNSentry.mm @@ -29,7 +29,6 @@ #import #import #import -#import #import // This guard prevents importing Hermes in JSC apps @@ -57,6 +56,7 @@ #import "RNSentryExperimentalOptions.h" #import "RNSentryVersion.h" #import "SentrySDKWrapper.h" +#import "SentryScreenFramesWrapper.h" static bool hasFetchedAppStart; @@ -580,21 +580,15 @@ - (void)stopObserving #if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST if (PrivateSentrySDKOnly.isFramesTrackingRunning) { - SentryScreenFrames *frames = PrivateSentrySDKOnly.currentScreenFrames; - - if (frames == nil) { + if (![SentryScreenFramesWrapper canTrackFrames]) { resolve(nil); return; } - NSNumber *total = [NSNumber numberWithLong:frames.total]; - NSNumber *frozen = [NSNumber numberWithLong:frames.frozen]; - NSNumber *slow = [NSNumber numberWithLong:frames.slow]; - resolve(@ { - @"totalFrames" : total, - @"frozenFrames" : frozen, - @"slowFrames" : slow, + @"totalFrames" : [SentryScreenFramesWrapper totalFrames], + @"frozenFrames" : [SentryScreenFramesWrapper frozenFrames], + @"slowFrames" : [SentryScreenFramesWrapper slowFrames], }); } else { resolve(nil); diff --git a/packages/core/ios/SentryScreenFramesWrapper.h b/packages/core/ios/SentryScreenFramesWrapper.h new file mode 100644 index 0000000000..b4d4ef07a4 --- /dev/null +++ b/packages/core/ios/SentryScreenFramesWrapper.h @@ -0,0 +1,10 @@ +#import + +@interface SentryScreenFramesWrapper : NSObject + ++ (BOOL)canTrackFrames; ++ (NSNumber *)totalFrames; ++ (NSNumber *)frozenFrames; ++ (NSNumber *)slowFrames; + +@end diff --git a/packages/core/ios/SentryScreenFramesWrapper.m b/packages/core/ios/SentryScreenFramesWrapper.m new file mode 100644 index 0000000000..1238b117c7 --- /dev/null +++ b/packages/core/ios/SentryScreenFramesWrapper.m @@ -0,0 +1,35 @@ +#import "SentryScreenFramesWrapper.h" +@import Sentry; + +@implementation SentryScreenFramesWrapper + ++ (BOOL)canTrackFrames +{ + return PrivateSentrySDKOnly.currentScreenFrames != nil; +} + ++ (NSNumber *)totalFrames +{ + if (![self canTrackFrames]) { + return nil; + } + return [NSNumber numberWithLong:PrivateSentrySDKOnly.currentScreenFrames.total]; +} + ++ (NSNumber *)frozenFrames +{ + if (![self canTrackFrames]) { + return nil; + } + return [NSNumber numberWithLong:PrivateSentrySDKOnly.currentScreenFrames.frozen]; +} + ++ (NSNumber *)slowFrames +{ + if (![self canTrackFrames]) { + return nil; + } + return [NSNumber numberWithLong:PrivateSentrySDKOnly.currentScreenFrames.slow]; +} + +@end From 5a09e8eb98d759948f52e718e1baa117fdd89f70 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Fri, 3 Oct 2025 14:37:22 -0300 Subject: [PATCH 2/6] Fix build --- packages/core/ios/SentryScreenFramesWrapper.h | 4 ++++ packages/core/ios/SentryScreenFramesWrapper.m | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/packages/core/ios/SentryScreenFramesWrapper.h b/packages/core/ios/SentryScreenFramesWrapper.h index b4d4ef07a4..4c664140e0 100644 --- a/packages/core/ios/SentryScreenFramesWrapper.h +++ b/packages/core/ios/SentryScreenFramesWrapper.h @@ -1,5 +1,7 @@ #import +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + @interface SentryScreenFramesWrapper : NSObject + (BOOL)canTrackFrames; @@ -8,3 +10,5 @@ + (NSNumber *)slowFrames; @end + +#endif // TARGET_OS_IPHONE || TARGET_OS_MACCATALYST diff --git a/packages/core/ios/SentryScreenFramesWrapper.m b/packages/core/ios/SentryScreenFramesWrapper.m index 1238b117c7..9df4e13070 100644 --- a/packages/core/ios/SentryScreenFramesWrapper.m +++ b/packages/core/ios/SentryScreenFramesWrapper.m @@ -1,6 +1,8 @@ #import "SentryScreenFramesWrapper.h" @import Sentry; +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + @implementation SentryScreenFramesWrapper + (BOOL)canTrackFrames @@ -33,3 +35,5 @@ + (NSNumber *)slowFrames } @end + +#endif // TARGET_OS_IPHONE || TARGET_OS_MACCATALYST From 7577a17161be29ab9953152e8e39391b6e488e3e Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 14 Oct 2025 15:58:47 +0200 Subject: [PATCH 3/6] Use non-experimental enableLogs --- packages/core/ios/RNSentryExperimentalOptions.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/ios/RNSentryExperimentalOptions.m b/packages/core/ios/RNSentryExperimentalOptions.m index 2e7db99a71..960c52db0d 100644 --- a/packages/core/ios/RNSentryExperimentalOptions.m +++ b/packages/core/ios/RNSentryExperimentalOptions.m @@ -24,7 +24,7 @@ + (void)setEnableLogs:(BOOL)enabled sentryOptions:(SentryOptions *)sentryOptions if (sentryOptions == nil) { return; } - sentryOptions.experimental.enableLogs = enabled; + sentryOptions.enableLogs = enabled; } @end From d3fe30631d01812ce380ff86ca536a44cfb23717 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 14 Oct 2025 16:26:20 +0200 Subject: [PATCH 4/6] bump target --- .../RNSentryCocoaTester.xcodeproj/project.pbxproj | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTester.xcodeproj/project.pbxproj b/packages/core/RNSentryCocoaTester/RNSentryCocoaTester.xcodeproj/project.pbxproj index 1c99c3a801..02284f6023 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTester.xcodeproj/project.pbxproj +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTester.xcodeproj/project.pbxproj @@ -236,10 +236,14 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-RNSentryCocoaTesterTests/Pods-RNSentryCocoaTesterTests-resources-${CONFIGURATION}-input-files.xcfilelist", ); + inputPaths = ( + ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-RNSentryCocoaTesterTests/Pods-RNSentryCocoaTesterTests-resources-${CONFIGURATION}-output-files.xcfilelist", ); + outputPaths = ( + ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNSentryCocoaTesterTests/Pods-RNSentryCocoaTesterTests-resources.sh\"\n"; @@ -434,7 +438,7 @@ "\"$(PODS_TARGET_SRCROOT)/include/\"", "\"${PODS_ROOT}/Sentry/Sources/Sentry/include\"", ); - IPHONEOS_DEPLOYMENT_TARGET = 12.4; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = io.sentry.RNSentryCocoaTesterTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -501,7 +505,7 @@ "\"$(PODS_TARGET_SRCROOT)/include/\"", "\"${PODS_ROOT}/Sentry/Sources/Sentry/include\"", ); - IPHONEOS_DEPLOYMENT_TARGET = 12.4; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = io.sentry.RNSentryCocoaTesterTests; PRODUCT_NAME = "$(TARGET_NAME)"; From 3bd04c2aaa7b5ac6aa5fa8c78aedefa2e27ae469 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 14 Oct 2025 16:52:51 +0200 Subject: [PATCH 5/6] remove enable tracing --- .../RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index 4c9a9d1e04..5be4d2bdec 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -36,7 +36,6 @@ - (void)testCreateOptionsWithDictionaryRemovesPerformanceProperties XCTAssertEqual( actualOptions.tracesSampleRate, nil, @"Traces sample rate should not be passed to native"); XCTAssertEqual(actualOptions.tracesSampler, nil, @"Traces sampler should not be passed to native"); -XCTAssertEqual(actualOptions.enableTracing, false, @"EnableTracing should not be passed to native"); } - (void)testCaptureFailedRequestsIsDisabled From cc596a89489fa246af64c4a87d2e14df2341c574 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Wed, 15 Oct 2025 10:18:38 +0200 Subject: [PATCH 6/6] Update enableLogs tests --- .../RNSentryCocoaTesterTests/RNSentryTests.m | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index 5be4d2bdec..66556e6e27 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -330,10 +330,7 @@ - (void)testCreateOptionsWithDictionaryEnableLogsEnabled XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); - id experimentalOptions = [actualOptions valueForKey:@"experimental"]; - XCTAssertNotNil(experimentalOptions, @"Experimental options should not be nil"); - - BOOL enableLogs = [[experimentalOptions valueForKey:@"enableLogs"] boolValue]; + BOOL enableLogs = [[actualOptions valueForKey:@"enableLogs"] boolValue]; XCTAssertTrue(enableLogs, @"enableLogs should be enabled"); } @@ -351,11 +348,8 @@ - (void)testCreateOptionsWithDictionaryEnableLogsDisabled XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); - - id experimentalOptions = [actualOptions valueForKey:@"experimental"]; - XCTAssertNotNil(experimentalOptions, @"Experimental options should not be nil"); - - BOOL enableLogs = [[experimentalOptions valueForKey:@"enableLogs"] boolValue]; + + BOOL enableLogs = [[actualOptions valueForKey:@"enableLogs"] boolValue]; XCTAssertFalse(enableLogs, @"enableLogs should be disabled"); }