diff --git a/CHANGELOG.md b/CHANGELOG.md index ed950203292..da146d2eba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Improvements + +- Reduced macOS SDK footprint by 2% (#3157) + ## 8.9.1 ### Fixes diff --git a/SentryTestUtils/ClearTestState.swift b/SentryTestUtils/ClearTestState.swift index 58be5ab4b58..911c79f2794 100644 --- a/SentryTestUtils/ClearTestState.swift +++ b/SentryTestUtils/ClearTestState.swift @@ -16,9 +16,7 @@ class TestCleanup: NSObject { SentrySDK.setCurrentHub(nil) SentrySDK.crashedLastRunCalled = false SentrySDK.startInvocations = 0 - PrivateSentrySDKOnly.onAppStartMeasurementAvailable = nil PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = false - SentrySDK.setAppStartMeasurement(nil) CurrentDate.setCurrentDateProvider(nil) SentryNetworkTracker.sharedInstance.disable() @@ -44,6 +42,11 @@ class TestCleanup: NSObject { #if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) SentryProfiler.getCurrent().stop(for: .normal) SentryTracer.resetConcurrencyTracking() -#endif +#endif // os(iOS) || os(macOS) || targetEnvironment(macCatalyst) + + #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + PrivateSentrySDKOnly.onAppStartMeasurementAvailable = nil + SentrySDK.setAppStartMeasurement(nil) + #endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) } } diff --git a/SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h b/SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h index 02ca400b8e4..0a344ae121f 100644 --- a/SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h +++ b/SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h @@ -1,20 +1,26 @@ +#import "SentryDefines.h" + +#if SENTRY_HAS_UIKIT +# import "SentryAppStartTracker.h" +# import "SentryDisplayLinkWrapper.h" +# import "SentryFramesTracker+TestInit.h" +# import "SentryUIDeviceWrapper.h" +# import "SentryUIViewControllerPerformanceTracker.h" +#endif // SENTRY_HAS_UIKIT + #import "PrivateSentrySDKOnly.h" -#import "SentryAppStartTracker.h" #import "SentryAppState.h" #import "SentryClient+Private.h" #import "SentryClient+TestInit.h" #import "SentryCrashWrapper.h" #import "SentryCurrentDate.h" #import "SentryCurrentDateProvider.h" -#import "SentryDefines.h" #import "SentryDependencyContainer.h" #import "SentryDispatchFactory.h" #import "SentryDispatchQueueWrapper.h" #import "SentryDispatchSourceWrapper.h" -#import "SentryDisplayLinkWrapper.h" #import "SentryEnvelope.h" #import "SentryFileManager.h" -#import "SentryFramesTracker+TestInit.h" #import "SentryGlobalEventProcessor.h" #import "SentryLog.h" #import "SentryNSProcessInfoWrapper.h" @@ -33,5 +39,3 @@ #import "SentryTracer+Test.h" #import "SentryTransport.h" #import "SentryTransportAdapter.h" -#import "SentryUIDeviceWrapper.h" -#import "SentryUIViewControllerPerformanceTracker.h" diff --git a/Sources/Sentry/Public/SentryDebugImageProvider.h b/Sources/Sentry/Public/SentryDebugImageProvider.h index fd0210a9584..12c3f08a0c3 100644 --- a/Sources/Sentry/Public/SentryDebugImageProvider.h +++ b/Sources/Sentry/Public/SentryDebugImageProvider.h @@ -1,4 +1,3 @@ -#import "SentryDefines.h" #import @class SentryDebugMeta, SentryThread, SentryFrame; diff --git a/Sources/Sentry/Public/SentryOptions.h b/Sources/Sentry/Public/SentryOptions.h index 6298d62bbf8..bb2db2b602e 100644 --- a/Sources/Sentry/Public/SentryOptions.h +++ b/Sources/Sentry/Public/SentryOptions.h @@ -246,7 +246,7 @@ NS_SWIFT_NAME(Options) */ @property (nonatomic, assign) BOOL enablePreWarmedAppStartTracing; -#endif +#endif // SENTRY_HAS_UIKIT /** * When enabled, the SDK tracks performance for HTTP requests if auto performance tracking and diff --git a/Sources/Sentry/SentryAppStartMeasurement.m b/Sources/Sentry/SentryAppStartMeasurement.m index 9b08bea66e3..eb9a3761d92 100644 --- a/Sources/Sentry/SentryAppStartMeasurement.m +++ b/Sources/Sentry/SentryAppStartMeasurement.m @@ -1,6 +1,9 @@ #import "SentryAppStartMeasurement.h" -#import "NSDate+SentryExtras.h" -#import + +#if SENTRY_HAS_UIKIT + +# import "NSDate+SentryExtras.h" +# import @implementation SentryAppStartMeasurement @@ -41,3 +44,5 @@ - (instancetype)initWithType:(SentryAppStartType)type } @end + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryAppStartTracker.m b/Sources/Sentry/SentryAppStartTracker.m index 3b351d1aabb..dc89ac99bae 100644 --- a/Sources/Sentry/SentryAppStartTracker.m +++ b/Sources/Sentry/SentryAppStartTracker.m @@ -1,18 +1,19 @@ -#import "SentryAppStartMeasurement.h" -#import "SentryAppStateManager.h" -#import "SentryLog.h" -#import "SentrySysctl.h" -#import -#import #import -#import -#import -#import -#import -#import -#import #if SENTRY_HAS_UIKIT + +# import "SentryAppStartMeasurement.h" +# import "SentryAppStateManager.h" +# import "SentryLog.h" +# import "SentrySysctl.h" +# import +# import +# import +# import +# import +# import +# import +# import # import static NSDate *runtimeInit = nil; @@ -82,9 +83,9 @@ - (BOOL)isActivePrewarmAvailable } else { return NO; } -# else +# else // !TARGET_OS_IOS return NO; -# endif +# endif // TARGET_OS_IOS } - (void)start @@ -116,7 +117,7 @@ - (void)start # if SENTRY_HAS_UIKIT [self.appStateManager start]; -# endif +# endif // SENTRY_HAS_UIKIT self.isRunning = YES; } @@ -312,4 +313,4 @@ - (void)setRuntimeInit:(NSDate *)value @end -#endif +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryAppStartTrackingIntegration.m b/Sources/Sentry/SentryAppStartTrackingIntegration.m index 14f4d7d8df9..ad0bee95eec 100644 --- a/Sources/Sentry/SentryAppStartTrackingIntegration.m +++ b/Sources/Sentry/SentryAppStartTrackingIntegration.m @@ -1,21 +1,22 @@ #import "SentryAppStartTrackingIntegration.h" -#import "SentryAppStartTracker.h" -#import "SentryDefaultCurrentDateProvider.h" -#import "SentryLog.h" -#import -#import -#import -#import -#import -#import -#import + +#if SENTRY_HAS_UIKIT + +# import "SentryAppStartTracker.h" +# import "SentryDefaultCurrentDateProvider.h" +# import "SentryLog.h" +# import +# import +# import +# import +# import +# import +# import @interface SentryAppStartTrackingIntegration () -#if SENTRY_HAS_UIKIT @property (nonatomic, strong) SentryAppStartTracker *tracker; -#endif @end @@ -23,7 +24,6 @@ @implementation SentryAppStartTrackingIntegration - (BOOL)installWithOptions:(SentryOptions *)options { -#if SENTRY_HAS_UIKIT if (!PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode && ![super installWithOptions:options]) { return NO; @@ -45,10 +45,6 @@ - (BOOL)installWithOptions:(SentryOptions *)options [self.tracker start]; return YES; -#else - SENTRY_LOG_DEBUG(@"NO UIKit -> SentryAppStartTracker will not track app start up time."); - return NO; -#endif } - (SentryIntegrationOption)integrationOptions @@ -63,11 +59,11 @@ - (void)uninstall - (void)stop { -#if SENTRY_HAS_UIKIT if (nil != self.tracker) { [self.tracker stop]; } -#endif } @end + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryCrashIntegration.m b/Sources/Sentry/SentryCrashIntegration.m index 47732bf5e2e..d0645f45430 100644 --- a/Sources/Sentry/SentryCrashIntegration.m +++ b/Sources/Sentry/SentryCrashIntegration.m @@ -69,6 +69,7 @@ - (BOOL)installWithOptions:(nonnull SentryOptions *)options self.options = options; +#if SENTRY_HAS_UIKIT SentryAppStateManager *appStateManager = [SentryDependencyContainer sharedInstance].appStateManager; SentryWatchdogTerminationLogic *logic = @@ -78,6 +79,10 @@ - (BOOL)installWithOptions:(nonnull SentryOptions *)options self.crashedSessionHandler = [[SentrySessionCrashedHandler alloc] initWithCrashWrapper:self.crashAdapter watchdogTerminationLogic:logic]; +#else + self.crashedSessionHandler = + [[SentrySessionCrashedHandler alloc] initWithCrashWrapper:self.crashAdapter]; +#endif // SENTRY_HAS_UIKIT self.scopeObserver = [[SentryCrashScopeObserver alloc] initWithMaxBreadcrumbs:options.maxBreadcrumbs]; diff --git a/Sources/Sentry/SentryDependencyContainer.m b/Sources/Sentry/SentryDependencyContainer.m index 7a3987f1ce0..cc0c37c7316 100644 --- a/Sources/Sentry/SentryDependencyContainer.m +++ b/Sources/Sentry/SentryDependencyContainer.m @@ -3,7 +3,6 @@ #import "SentryDispatchFactory.h" #import "SentryDispatchQueueWrapper.h" #import "SentryDisplayLinkWrapper.h" -#import "SentryFramesTracker.h" #import "SentryNSProcessInfoWrapper.h" #import "SentryNSTimerFactory.h" #import "SentrySystemWrapper.h" @@ -24,6 +23,10 @@ #import #import +#if SENTRY_HAS_UIKIT +# import "SentryFramesTracker.h" +#endif // SENTRY_HAS_UIKIT + @implementation SentryDependencyContainer static SentryDependencyContainer *instance; diff --git a/Sources/Sentry/SentryFramesTracker.m b/Sources/Sentry/SentryFramesTracker.m index 5627d3eb8c0..1d645d74c10 100644 --- a/Sources/Sentry/SentryFramesTracker.m +++ b/Sources/Sentry/SentryFramesTracker.m @@ -1,16 +1,18 @@ #import "SentryFramesTracker.h" -#import "SentryCompiler.h" -#import "SentryCurrentDate.h" -#import "SentryDisplayLinkWrapper.h" -#import "SentryLog.h" -#import "SentryProfiler.h" -#import "SentryProfilingConditionals.h" -#import "SentryTime.h" -#import "SentryTracer.h" -#import -#include #if SENTRY_HAS_UIKIT + +# import "SentryCompiler.h" +# import "SentryCurrentDate.h" +# import "SentryDisplayLinkWrapper.h" +# import "SentryLog.h" +# import "SentryProfiler.h" +# import "SentryProfilingConditionals.h" +# import "SentryTime.h" +# import "SentryTracer.h" +# import +# include + # import # if SENTRY_TARGET_PROFILING_SUPPORTED @@ -182,7 +184,7 @@ - (void)recordTimestamp:(uint64_t)timestamp value:(NSNumber *)value array:(NSMut BOOL shouldRecord = [SentryProfiler isCurrentlyProfiling]; # if defined(TEST) || defined(TESTCI) shouldRecord = YES; -# endif +# endif // defined(TEST) || defined(TESTCI) if (shouldRecord) { [array addObject:@{ @"timestamp" : @(timestamp), @"value" : value }]; } @@ -228,4 +230,4 @@ - (void)removeListener:(id)listener @end -#endif +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryFramesTrackingIntegration.m b/Sources/Sentry/SentryFramesTrackingIntegration.m index e0c28e05483..a1916b682e6 100644 --- a/Sources/Sentry/SentryFramesTrackingIntegration.m +++ b/Sources/Sentry/SentryFramesTrackingIntegration.m @@ -1,17 +1,19 @@ #import "SentryFramesTrackingIntegration.h" -#import "PrivateSentrySDKOnly.h" -#import "SentryDependencyContainer.h" -#import "SentryFramesTracker.h" -#import "SentryLog.h" + +#if SENTRY_HAS_UIKIT + +# import "PrivateSentrySDKOnly.h" +# import "SentryDependencyContainer.h" +# import "SentryLog.h" + +# import "SentryFramesTracker.h" NS_ASSUME_NONNULL_BEGIN @interface SentryFramesTrackingIntegration () -#if SENTRY_HAS_UIKIT @property (nonatomic, strong) SentryFramesTracker *tracker; -#endif @end @@ -19,7 +21,6 @@ @implementation SentryFramesTrackingIntegration - (BOOL)installWithOptions:(SentryOptions *)options { -#if SENTRY_HAS_UIKIT if (!PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode && ![super installWithOptions:options]) { return NO; @@ -29,14 +30,6 @@ - (BOOL)installWithOptions:(SentryOptions *)options [self.tracker start]; return YES; -#else - [SentryLog - logWithMessage: - @"NO UIKit -> SentryFramesTrackingIntegration will not track slow and frozen frames." - andLevel:kSentryLevelInfo]; - - return NO; -#endif } - (SentryIntegrationOption)integrationOptions @@ -51,13 +44,13 @@ - (void)uninstall - (void)stop { -#if SENTRY_HAS_UIKIT if (nil != self.tracker) { [self.tracker stop]; } -#endif } @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryHub.m b/Sources/Sentry/SentryHub.m index 1321aae42d8..c265af511c5 100644 --- a/Sources/Sentry/SentryHub.m +++ b/Sources/Sentry/SentryHub.m @@ -24,7 +24,10 @@ #import "SentryTracesSampler.h" #import "SentryTransaction.h" #import "SentryTransactionContext+Private.h" -#import "SentryUIViewControllerPerformanceTracker.h" + +#if SENTRY_HAS_UIKIT +# import "SentryUIViewControllerPerformanceTracker.h" +#endif // SENTRY_HAS_UIKIT NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/SentryOptions.m b/Sources/Sentry/SentryOptions.m index 8d6f5537c2e..42ab68a4b31 100644 --- a/Sources/Sentry/SentryOptions.m +++ b/Sources/Sentry/SentryOptions.m @@ -1,12 +1,31 @@ #import "SentryOptions.h" #import "SentryANRTracker.h" +#import "SentryANRTrackingIntegration.h" +#import "SentryAutoBreadcrumbTrackingIntegration.h" +#import "SentryAutoSessionTrackingIntegration.h" +#import "SentryCoreDataTrackingIntegration.h" +#import "SentryCrashIntegration.h" #import "SentryDsn.h" +#import "SentryFileIOTrackingIntegration.h" #import "SentryHttpStatusCodeRange.h" #import "SentryLevelMapper.h" #import "SentryLog.h" #import "SentryMeta.h" +#import "SentryMetricKitIntegration.h" +#import "SentryNetworkTrackingIntegration.h" #import "SentrySDK.h" #import "SentryScope.h" +#import "SentrySwiftAsyncIntegration.h" + +#if SENTRY_HAS_UIKIT +# import "SentryAppStartTrackingIntegration.h" +# import "SentryFramesTrackingIntegration.h" +# import "SentryPerformanceTrackingIntegration.h" +# import "SentryScreenshotIntegration.h" +# import "SentryUIEventTrackingIntegration.h" +# import "SentryViewHierarchyIntegration.h" +# import "SentryWatchdogTerminationTrackingIntegration.h" +#endif // SENTRY_HAS_UIKIT @interface SentryOptions () @@ -34,23 +53,31 @@ - (void)setMeasurement:(SentryMeasurementValue *)measurement { NSMutableArray *defaultIntegrations = @[ - @"SentryCrashIntegration", #if SENTRY_HAS_UIKIT - @"SentryScreenshotIntegration", @"SentryUIEventTrackingIntegration", - @"SentryViewHierarchyIntegration", + NSStringFromClass([SentryAppStartTrackingIntegration class]), + NSStringFromClass([SentryFramesTrackingIntegration class]), + NSStringFromClass([SentryPerformanceTrackingIntegration class]), + NSStringFromClass([SentryScreenshotIntegration class]), + NSStringFromClass([SentryUIEventTrackingIntegration class]), + NSStringFromClass([SentryViewHierarchyIntegration class]), + NSStringFromClass([SentryWatchdogTerminationTrackingIntegration class]), #endif - @"SentryANRTrackingIntegration", @"SentryFramesTrackingIntegration", - @"SentryAutoBreadcrumbTrackingIntegration", @"SentryAutoSessionTrackingIntegration", - @"SentryAppStartTrackingIntegration", @"SentryWatchdogTerminationTrackingIntegration", - @"SentryPerformanceTrackingIntegration", @"SentryNetworkTrackingIntegration", - @"SentryFileIOTrackingIntegration", @"SentryCoreDataTrackingIntegration", - @"SentrySwiftAsyncIntegration" + NSStringFromClass([SentryANRTrackingIntegration class]), + NSStringFromClass([SentryAutoBreadcrumbTrackingIntegration class]), + NSStringFromClass([SentryAutoSessionTrackingIntegration class]), + NSStringFromClass([SentryCoreDataTrackingIntegration class]), + NSStringFromClass([SentryCrashIntegration class]), + NSStringFromClass([SentryFileIOTrackingIntegration class]), + NSStringFromClass([SentryNetworkTrackingIntegration class]), + NSStringFromClass([SentrySwiftAsyncIntegration class]) ] .mutableCopy; +#if SENTRY_HAS_METRICKIT if (@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, *)) { - [defaultIntegrations addObject:@"SentryMetricKitIntegration"]; + [defaultIntegrations addObject:NSStringFromClass([SentryMetricKitIntegration class])]; } +#endif // SENTRY_HAS_METRICKIT return defaultIntegrations; } diff --git a/Sources/Sentry/SentryPerformanceTracker.m b/Sources/Sentry/SentryPerformanceTracker.m index 85b968c0485..6dc1572a069 100644 --- a/Sources/Sentry/SentryPerformanceTracker.m +++ b/Sources/Sentry/SentryPerformanceTracker.m @@ -8,7 +8,10 @@ #import "SentrySpanProtocol.h" #import "SentryTracer.h" #import "SentryTransactionContext+Private.h" -#import "SentryUIEventTracker.h" + +#if SENTRY_HAS_UIKIT +# import "SentryUIEventTracker.h" +#endif // SENTRY_HAS_UIKIT NS_ASSUME_NONNULL_BEGIN @@ -60,18 +63,20 @@ - (SentrySpanId *)startSpanWithName:(NSString *)name origin:origin]; [SentrySDK.currentHub.scope useSpan:^(id span) { - BOOL bindToScope = YES; - if (span != nil) { + BOOL bindToScope = NO; + if (span == nil) { + bindToScope = YES; + } +#if SENTRY_HAS_UIKIT + else { if ([SentryUIEventTracker isUIEventOperation:span.operation]) { SENTRY_LOG_DEBUG( @"Cancelling previous UI event span %@", span.spanId.sentrySpanIdString); [span finishWithStatus:kSentrySpanStatusCancelled]; - } else { - SENTRY_LOG_DEBUG(@"Current scope span %@ is not tracking a UI event", - span.spanId.sentrySpanIdString); - bindToScope = NO; + bindToScope = YES; } } +#endif // SENTRY_HAS_UIKIT SENTRY_LOG_DEBUG(@"Creating new transaction bound to scope: %d", bindToScope); diff --git a/Sources/Sentry/SentryPerformanceTrackingIntegration.m b/Sources/Sentry/SentryPerformanceTrackingIntegration.m index 82cfd131d8e..ae5ea0c2fe8 100644 --- a/Sources/Sentry/SentryPerformanceTrackingIntegration.m +++ b/Sources/Sentry/SentryPerformanceTrackingIntegration.m @@ -1,19 +1,20 @@ #import "SentryPerformanceTrackingIntegration.h" -#import "SentryDefaultObjCRuntimeWrapper.h" -#import "SentryDependencyContainer.h" -#import "SentryDispatchQueueWrapper.h" -#import "SentryLog.h" -#import "SentryNSProcessInfoWrapper.h" -#import "SentrySubClassFinder.h" -#import "SentryUIViewControllerPerformanceTracker.h" -#import "SentryUIViewControllerSwizzling.h" + +#if SENTRY_HAS_UIKIT + +# import "SentryDefaultObjCRuntimeWrapper.h" +# import "SentryDependencyContainer.h" +# import "SentryDispatchQueueWrapper.h" +# import "SentryLog.h" +# import "SentryNSProcessInfoWrapper.h" +# import "SentrySubClassFinder.h" +# import "SentryUIViewControllerPerformanceTracker.h" +# import "SentryUIViewControllerSwizzling.h" @interface SentryPerformanceTrackingIntegration () -#if SENTRY_HAS_UIKIT @property (nonatomic, strong) SentryUIViewControllerSwizzling *swizzling; -#endif @end @@ -21,7 +22,6 @@ @implementation SentryPerformanceTrackingIntegration - (BOOL)installWithOptions:(SentryOptions *)options { -#if SENTRY_HAS_UIKIT if (![super installWithOptions:options]) { return NO; } @@ -48,10 +48,6 @@ - (BOOL)installWithOptions:(SentryOptions *)options = options.enableTimeToFullDisplayTracing; return YES; -#else - SENTRY_LOG_DEBUG(@"NO UIKit -> [SentryPerformanceTrackingIntegration start] does nothing."); - return NO; -#endif } - (SentryIntegrationOption)integrationOptions @@ -62,3 +58,5 @@ - (SentryIntegrationOption)integrationOptions } @end + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryScreenshot.m b/Sources/Sentry/SentryScreenshot.m index 91bb2e90e2b..4e07b5ed23d 100644 --- a/Sources/Sentry/SentryScreenshot.m +++ b/Sources/Sentry/SentryScreenshot.m @@ -1,10 +1,11 @@ #import "SentryScreenshot.h" -#import "SentryCompiler.h" -#import "SentryDependencyContainer.h" -#import "SentryDispatchQueueWrapper.h" -#import "SentryUIApplication.h" #if SENTRY_HAS_UIKIT + +# import "SentryCompiler.h" +# import "SentryDependencyContainer.h" +# import "SentryDispatchQueueWrapper.h" +# import "SentryUIApplication.h" # import @implementation SentryScreenshot @@ -72,4 +73,4 @@ - (void)saveScreenShots:(NSString *)imagesDirectoryPath @end -#endif +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryScreenshotIntegration.m b/Sources/Sentry/SentryScreenshotIntegration.m index 4f778062250..60a478e14e2 100644 --- a/Sources/Sentry/SentryScreenshotIntegration.m +++ b/Sources/Sentry/SentryScreenshotIntegration.m @@ -1,14 +1,15 @@ #import "SentryScreenshotIntegration.h" -#import "SentryAttachment.h" -#import "SentryCrashC.h" -#import "SentryDependencyContainer.h" -#import "SentryEvent+Private.h" -#import "SentryHub+Private.h" -#import "SentryMetricKitIntegration.h" -#import "SentrySDK+Private.h" #if SENTRY_HAS_UIKIT +# import "SentryAttachment.h" +# import "SentryCrashC.h" +# import "SentryDependencyContainer.h" +# import "SentryEvent+Private.h" +# import "SentryHub+Private.h" +# import "SentryMetricKitIntegration.h" +# import "SentrySDK+Private.h" + void saveScreenShot(const char *path) { @@ -76,4 +77,5 @@ - (void)uninstall } @end -#endif + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentrySessionCrashedHandler.m b/Sources/Sentry/SentrySessionCrashedHandler.m index 24eaee0d1e9..b9927d6f6d6 100644 --- a/Sources/Sentry/SentrySessionCrashedHandler.m +++ b/Sources/Sentry/SentrySessionCrashedHandler.m @@ -11,26 +11,37 @@ SentrySessionCrashedHandler () @property (nonatomic, strong) SentryCrashWrapper *crashWrapper; +#if SENTRY_HAS_UIKIT @property (nonatomic, strong) SentryWatchdogTerminationLogic *watchdogTerminationLogic; +#endif // SENTRY_HAS_UIKIT @end @implementation SentrySessionCrashedHandler +#if SENTRY_HAS_UIKIT - (instancetype)initWithCrashWrapper:(SentryCrashWrapper *)crashWrapper - watchdogTerminationLogic:(SentryWatchdogTerminationLogic *)watchdogTerminationLogic; + watchdogTerminationLogic:(SentryWatchdogTerminationLogic *)watchdogTerminationLogic +#else +- (instancetype)initWithCrashWrapper:(SentryCrashWrapper *)crashWrapper +#endif // SENTRY_HAS_UIKIT { self = [self init]; self.crashWrapper = crashWrapper; +#if SENTRY_HAS_UIKIT self.watchdogTerminationLogic = watchdogTerminationLogic; +#endif // SENTRY_HAS_UIKIT return self; } - (void)endCurrentSessionAsCrashedWhenCrashOrOOM { - if (self.crashWrapper.crashedLastLaunch || - [self.watchdogTerminationLogic isWatchdogTermination]) { + if (self.crashWrapper.crashedLastLaunch +#if SENTRY_HAS_UIKIT + || [self.watchdogTerminationLogic isWatchdogTermination] +#endif // SENTRY_HAS_UIKIT + ) { SentryFileManager *fileManager = [[[SentrySDK currentHub] getClient] fileManager]; if (nil == fileManager) { diff --git a/Sources/Sentry/SentryTimeToDisplayTracker.m b/Sources/Sentry/SentryTimeToDisplayTracker.m index 5a12a24364c..1dfcf0c2a50 100644 --- a/Sources/Sentry/SentryTimeToDisplayTracker.m +++ b/Sources/Sentry/SentryTimeToDisplayTracker.m @@ -1,18 +1,19 @@ #import "SentryTimeToDisplayTracker.h" -#import "SentryCurrentDate.h" -#import "SentryDependencyContainer.h" -#import "SentryFramesTracker.h" -#import "SentryMeasurementValue.h" -#import "SentrySpan.h" -#import "SentrySpanContext.h" -#import "SentrySpanId.h" -#import "SentrySpanOperations.h" -#import "SentrySwift.h" -#import "SentryTraceOrigins.h" -#import "SentryTracer.h" #if SENTRY_HAS_UIKIT +# import "SentryCurrentDate.h" +# import "SentryDependencyContainer.h" +# import "SentryFramesTracker.h" +# import "SentryMeasurementValue.h" +# import "SentrySpan.h" +# import "SentrySpanContext.h" +# import "SentrySpanId.h" +# import "SentrySpanOperations.h" +# import "SentrySwift.h" +# import "SentryTraceOrigins.h" +# import "SentryTracer.h" + @interface SentryTimeToDisplayTracker () @@ -127,4 +128,5 @@ - (void)trimTTFDIdNecessaryForTracer:(SentryTracer *)tracer } @end -#endif + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryTracer.m b/Sources/Sentry/SentryTracer.m index 1722022f21c..801dfbcd3f1 100644 --- a/Sources/Sentry/SentryTracer.m +++ b/Sources/Sentry/SentryTracer.m @@ -1,19 +1,15 @@ #import "SentryTracer.h" #import "NSDictionary+SentrySanitize.h" #import "PrivateSentrySDKOnly.h" -#import "SentryAppStartMeasurement.h" #import "SentryClient.h" #import "SentryCurrentDate.h" #import "SentryDebugImageProvider.h" #import "SentryDependencyContainer.h" #import "SentryEvent+Private.h" -#import "SentryFramesTracker.h" #import "SentryHub+Private.h" #import "SentryLog.h" #import "SentryNSTimerFactory.h" #import "SentryNoOpSpan.h" -#import "SentryProfiledTracerConcurrency.h" -#import "SentryProfiler.h" #import "SentryProfilesSampler.h" #import "SentryProfilingConditionals.h" #import "SentrySDK+Private.h" @@ -28,22 +24,35 @@ #import "SentryTraceOrigins.h" #import "SentryTransaction.h" #import "SentryTransactionContext.h" -#import "SentryUIViewControllerPerformanceTracker.h" #import #import #import -#import #import +#if SENTRY_TARGET_PROFILING_SUPPORTED +# import "SentryProfiledTracerConcurrency.h" +# import "SentryProfiler.h" +#endif // SENTRY_TARGET_PROFILING_SUPPORTED + +#if SENTRY_HAS_UIKIT +# import "SentryAppStartMeasurement.h" +# import "SentryFramesTracker.h" +# import "SentryUIViewControllerPerformanceTracker.h" +# import +#endif // SENTRY_HAS_UIKIT + NS_ASSUME_NONNULL_BEGIN static const void *spanTimestampObserver = &spanTimestampObserver; +#if SENTRY_HAS_UIKIT /** * The maximum amount of seconds the app start measurement end time and the start time of the * transaction are allowed to be apart. */ static const NSTimeInterval SENTRY_APP_START_MEASUREMENT_DIFFERENCE = 5.0; +#endif // SENTRY_HAS_UIKIT + static const NSTimeInterval SENTRY_AUTO_TRANSACTION_MAX_DURATION = 500.0; static const NSTimeInterval SENTRY_AUTO_TRANSACTION_DEADLINE = 30.0; @@ -70,7 +79,10 @@ @implementation SentryTracer { /** Wether the tracer should wait for child spans to finish before finishing itself. */ SentryTraceContext *_traceContext; + +#if SENTRY_HAS_UIKIT SentryAppStartMeasurement *appStartMeasurement; +#endif // SENTRY_HAS_UIKIT NSMutableDictionary *_measurements; dispatch_block_t _idleTimeoutBlock; NSMutableArray> *_children; @@ -82,7 +94,7 @@ @implementation SentryTracer { NSUInteger initTotalFrames; NSUInteger initSlowFrames; NSUInteger initFrozenFrames; -#endif +#endif // SENTRY_HAS_UIKIT } static NSObject *appStartMeasurementLock; @@ -125,7 +137,9 @@ - (instancetype)initWithTransactionContext:(SentryTransactionContext *)transacti _configuration.timerFactory = [[SentryNSTimerFactory alloc] init]; } +#if SENTRY_HAS_UIKIT appStartMeasurement = [self getAppStartMeasurement]; +#endif // SENTRY_HAS_UIKIT _idleTimeoutLock = [[NSObject alloc] init]; if ([self hasIdleTimeout]) { @@ -449,9 +463,11 @@ - (void)finishInternal self.finishCallback = nil; } +#if SENTRY_HAS_UIKIT if (appStartMeasurement != nil) { [self updateStartTime:appStartMeasurement.appStartTimestamp]; } +#endif // SENTRY_HAS_UIKIT // Prewarming can execute code up to viewDidLoad of a UIViewController, and keep the app in the // background. This can lead to auto-generated transactions lasting for minutes or even hours. @@ -553,15 +569,23 @@ - (void)updateStartTime:(NSDate *)startTime - (SentryTransaction *)toTransaction { + NSUInteger capacity; +#if SENTRY_HAS_UIKIT NSArray> *appStartSpans = [self buildAppStartSpans]; + capacity = _children.count + appStartSpans.count; +#else + capacity = _children.count; +#endif // SENTRY_HAS_UIKIT - NSMutableArray> *spans = - [[NSMutableArray alloc] initWithCapacity:_children.count + appStartSpans.count]; + NSMutableArray> *spans = [[NSMutableArray alloc] initWithCapacity:capacity]; @synchronized(_children) { [spans addObjectsFromArray:_children]; } + +#if SENTRY_HAS_UIKIT [spans addObjectsFromArray:appStartSpans]; +#endif // SENTRY_HAS_UIKIT SentryTransaction *transaction = [[SentryTransaction alloc] initWithTrace:self children:spans]; transaction.transaction = self.transactionContext.name; @@ -588,10 +612,15 @@ - (SentryTransaction *)toTransaction isCrash:NO]; } +#if SENTRY_HAS_UIKIT [self addMeasurements:transaction]; +#endif // SENTRY_HAS_UIKIT + return transaction; } +#if SENTRY_HAS_UIKIT + - (nullable SentryAppStartMeasurement *)getAppStartMeasurement { // Only send app start measurement for transactions generated by auto performance @@ -733,7 +762,6 @@ - (void)addMeasurements:(SentryTransaction *)transaction } } -#if SENTRY_HAS_UIKIT // Frames SentryFramesTracker *framesTracker = SentryDependencyContainer.sharedInstance.framesTracker; if (framesTracker.isRunning && !_startTimeChanged) { @@ -755,9 +783,10 @@ - (void)addMeasurements:(SentryTransaction *)transaction self.operation, (long)totalFrames, (long)slowFrames, (long)frozenFrames); } } -#endif } +#endif // SENTRY_HAS_UIKIT + - (id)buildSpan:(SentrySpanId *)parentId operation:(NSString *)operation description:(NSString *)description diff --git a/Sources/Sentry/SentryUIApplication.m b/Sources/Sentry/SentryUIApplication.m index b39d741a7ea..1d84f9271ff 100644 --- a/Sources/Sentry/SentryUIApplication.m +++ b/Sources/Sentry/SentryUIApplication.m @@ -56,4 +56,4 @@ - (UIApplication *)sharedApplication @end -#endif +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryUIEventTracker.m b/Sources/Sentry/SentryUIEventTracker.m index ae67853512e..07a114a311c 100644 --- a/Sources/Sentry/SentryUIEventTracker.m +++ b/Sources/Sentry/SentryUIEventTracker.m @@ -1,18 +1,19 @@ -#import "SentrySwizzleWrapper.h" -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import #import #if SENTRY_HAS_UIKIT + +# import "SentrySwizzleWrapper.h" +# import +# import +# import +# import +# import +# import +# import +# import +# import +# import +# import # import NS_ASSUME_NONNULL_BEGIN @@ -30,12 +31,8 @@ @end -#endif - @implementation SentryUIEventTracker -#if SENTRY_HAS_UIKIT - - (instancetype)initWithSwizzleWrapper:(SentrySwizzleWrapper *)swizzleWrapper dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper idleTimeout:(NSTimeInterval)idleTimeout @@ -208,12 +205,6 @@ - (NSString *)getTransactionName:(NSString *)action target:(NSString *)target return [NSString stringWithFormat:@"%@.%@", target, components.firstObject]; } -NS_ASSUME_NONNULL_END - -#endif - -NS_ASSUME_NONNULL_BEGIN - + (BOOL)isUIEventOperation:(NSString *)operation { if ([operation isEqualToString:SentrySpanOperationUIAction]) { @@ -228,3 +219,5 @@ + (BOOL)isUIEventOperation:(NSString *)operation @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryUIEventTrackingIntegration.m b/Sources/Sentry/SentryUIEventTrackingIntegration.m index b68a528a181..e70ae2b65bf 100644 --- a/Sources/Sentry/SentryUIEventTrackingIntegration.m +++ b/Sources/Sentry/SentryUIEventTrackingIntegration.m @@ -1,13 +1,14 @@ #import "SentryUIEventTrackingIntegration.h" -#import -#import -#import -#import -#import -#import -#import #if SENTRY_HAS_UIKIT + +# import +# import +# import +# import +# import +# import + @interface SentryUIEventTrackingIntegration () @@ -48,4 +49,5 @@ - (void)uninstall } @end -#endif + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryUIViewControllerPerformanceTracker.m b/Sources/Sentry/SentryUIViewControllerPerformanceTracker.m index 330ae4d3637..adf493d15a4 100644 --- a/Sources/Sentry/SentryUIViewControllerPerformanceTracker.m +++ b/Sources/Sentry/SentryUIViewControllerPerformanceTracker.m @@ -1,21 +1,22 @@ #import "SentryUIViewControllerPerformanceTracker.h" -#import "SentryFramesTracker.h" -#import "SentryHub.h" -#import "SentryLog.h" -#import "SentryPerformanceTracker.h" -#import "SentrySDK+Private.h" -#import "SentryScope.h" -#import "SentrySpanId.h" -#import "SentrySwift.h" -#import "SentryTimeToDisplayTracker.h" -#import "SentryTraceOrigins.h" -#import "SentryTracer.h" -#import -#import -#import #if SENTRY_HAS_UIKIT +# import "SentryFramesTracker.h" +# import "SentryHub.h" +# import "SentryLog.h" +# import "SentryPerformanceTracker.h" +# import "SentrySDK+Private.h" +# import "SentryScope.h" +# import "SentrySpanId.h" +# import "SentrySwift.h" +# import "SentryTimeToDisplayTracker.h" +# import "SentryTraceOrigins.h" +# import "SentryTracer.h" +# import +# import +# import + @interface SentryUIViewControllerPerformanceTracker () @@ -403,4 +404,4 @@ - (void)measurePerformance:(NSString *)description @end -#endif +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryUIViewControllerSwizzling.m b/Sources/Sentry/SentryUIViewControllerSwizzling.m index 8539138db84..3bb277931c8 100644 --- a/Sources/Sentry/SentryUIViewControllerSwizzling.m +++ b/Sources/Sentry/SentryUIViewControllerSwizzling.m @@ -1,18 +1,19 @@ #import "SentryUIViewControllerSwizzling.h" -#import "SentryDefaultObjCRuntimeWrapper.h" -#import "SentryLog.h" -#import "SentryNSProcessInfoWrapper.h" -#import "SentrySubClassFinder.h" -#import "SentrySwizzle.h" -#import "SentryUIViewControllerPerformanceTracker.h" -#import -#import -#import -#import -#import #if SENTRY_HAS_UIKIT + +# import "SentryDefaultObjCRuntimeWrapper.h" +# import "SentryLog.h" +# import "SentryNSProcessInfoWrapper.h" +# import "SentrySubClassFinder.h" +# import "SentrySwizzle.h" +# import "SentryUIViewControllerPerformanceTracker.h" +# import +# import +# import # import +# import +# import /** * @c swizzleRootViewControllerFromUIApplication: requires an object that conforms to @@ -442,4 +443,5 @@ - (void)swizzleViewLayoutSubViews:(Class)class @end # pragma clang diagnostic pop -#endif + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryViewHierarchy.m b/Sources/Sentry/SentryViewHierarchy.m index 21a05b8cfc0..34b7714d7dd 100644 --- a/Sources/Sentry/SentryViewHierarchy.m +++ b/Sources/Sentry/SentryViewHierarchy.m @@ -1,16 +1,17 @@ #import "SentryViewHierarchy.h" -#import "SentryCrashFileUtils.h" -#import "SentryCrashJSONCodec.h" -#import "SentryDependencyContainer.h" -#import "SentryLog.h" -#import "SentryUIApplication.h" -#import "UIView+Sentry.h" - -@import SentryPrivate; #if SENTRY_HAS_UIKIT + +# import "SentryCrashFileUtils.h" +# import "SentryCrashJSONCodec.h" +# import "SentryDependencyContainer.h" +# import "SentryLog.h" +# import "SentryUIApplication.h" +# import "UIView+Sentry.h" # import +@import SentryPrivate; + static int writeJSONDataToFile(const char *const data, const int length, void *const userData) { @@ -150,4 +151,4 @@ - (int)viewHierarchyFromView:(UIView *)view intoContext:(SentryCrashJSONEncodeCo @end -#endif +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryViewHierarchyIntegration.m b/Sources/Sentry/SentryViewHierarchyIntegration.m index f159349a735..e2b68daeadf 100644 --- a/Sources/Sentry/SentryViewHierarchyIntegration.m +++ b/Sources/Sentry/SentryViewHierarchyIntegration.m @@ -1,14 +1,14 @@ #import "SentryViewHierarchyIntegration.h" -#import "SentryAttachment+Private.h" -#import "SentryCrashC.h" -#import "SentryDependencyContainer.h" -#import "SentryEvent+Private.h" -#import "SentryHub+Private.h" -#import "SentryMetricKitIntegration.h" -#import "SentrySDK+Private.h" -#import "SentryViewHierarchy.h" #if SENTRY_HAS_UIKIT +# import "SentryAttachment+Private.h" +# import "SentryCrashC.h" +# import "SentryDependencyContainer.h" +# import "SentryEvent+Private.h" +# import "SentryHub+Private.h" +# import "SentryMetricKitIntegration.h" +# import "SentrySDK+Private.h" +# import "SentryViewHierarchy.h" /** * Function to call through to the ObjC method to save a view hierarchy, which can be passed around diff --git a/Sources/Sentry/SentryWatchdogTerminationLogic.m b/Sources/Sentry/SentryWatchdogTerminationLogic.m index 5b1169a49c2..2e6ff67139e 100644 --- a/Sources/Sentry/SentryWatchdogTerminationLogic.m +++ b/Sources/Sentry/SentryWatchdogTerminationLogic.m @@ -1,14 +1,14 @@ -#import -#import -#import -#import -#import -#import #import #if SENTRY_HAS_UIKIT + +# import +# import +# import +# import +# import +# import # import -#endif @interface SentryWatchdogTerminationLogic () @@ -39,7 +39,6 @@ - (BOOL)isWatchdogTermination return NO; } -#if SENTRY_HAS_UIKIT SentryAppState *previousAppState = [self.appStateManager loadPreviousAppState]; SentryAppState *currentAppState = [self.appStateManager buildCurrentAppState]; @@ -107,11 +106,8 @@ - (BOOL)isWatchdogTermination } return YES; -#else - // We can only track Watchdog Terminations for iOS, tvOS and macCatalyst. Therefore we return NO - // for other platforms. - return NO; -#endif } @end + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryWatchdogTerminationScopeObserver.m b/Sources/Sentry/SentryWatchdogTerminationScopeObserver.m index 60a159eb6cb..a18effbcdec 100644 --- a/Sources/Sentry/SentryWatchdogTerminationScopeObserver.m +++ b/Sources/Sentry/SentryWatchdogTerminationScopeObserver.m @@ -1,7 +1,10 @@ #import "SentryWatchdogTerminationScopeObserver.h" -#import -#import -#import + +#if SENTRY_HAS_UIKIT + +# import +# import +# import @interface SentryWatchdogTerminationScopeObserver () @@ -160,3 +163,5 @@ - (void)setUser:(nullable SentryUser *)user } @end + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentryWatchdogTerminationTracker.m b/Sources/Sentry/SentryWatchdogTerminationTracker.m index cc4dbe3d419..02eba499a86 100644 --- a/Sources/Sentry/SentryWatchdogTerminationTracker.m +++ b/Sources/Sentry/SentryWatchdogTerminationTracker.m @@ -18,7 +18,7 @@ #if SENTRY_HAS_UIKIT # import -#endif +#endif // SENTRY_HAS_UIKIT @interface SentryWatchdogTerminationTracker () @@ -89,18 +89,18 @@ - (void)start [SentrySDK captureCrashEvent:event]; } }]; -#else +#else // !SENTRY_HAS_UIKIT SENTRY_LOG_INFO( @"NO UIKit -> SentryWatchdogTerminationTracker will not track Watchdog Terminations."); return; -#endif +#endif // SENTRY_HAS_UIKIT } - (void)stop { #if SENTRY_HAS_UIKIT [self.appStateManager stop]; -#endif +#endif // SENTRY_HAS_UIKIT } @end diff --git a/Sources/Sentry/SentryWatchdogTerminationTrackingIntegration.m b/Sources/Sentry/SentryWatchdogTerminationTrackingIntegration.m index 8ebe0f6736c..7756f9be4b4 100644 --- a/Sources/Sentry/SentryWatchdogTerminationTrackingIntegration.m +++ b/Sources/Sentry/SentryWatchdogTerminationTrackingIntegration.m @@ -1,19 +1,21 @@ -#import "SentryDefines.h" -#import "SentryScope+Private.h" -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import #import +#if SENTRY_HAS_UIKIT + +# import "SentryScope+Private.h" +# import +# import +# import +# import +# import +# import +# import +# import +# import +# import +# import +# import + NS_ASSUME_NONNULL_BEGIN @interface @@ -103,20 +105,18 @@ - (void)uninstall - (void)anrDetected { -#if SENTRY_HAS_UIKIT [self.appStateManager updateAppState:^(SentryAppState *appState) { appState.isANROngoing = YES; }]; -#endif } - (void)anrStopped { -#if SENTRY_HAS_UIKIT [self.appStateManager updateAppState:^(SentryAppState *appState) { appState.isANROngoing = NO; }]; -#endif } @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/HybridPublic/SentryAppStartMeasurement.h b/Sources/Sentry/include/HybridPublic/SentryAppStartMeasurement.h index 729da075e1c..5e33c1b8747 100644 --- a/Sources/Sentry/include/HybridPublic/SentryAppStartMeasurement.h +++ b/Sources/Sentry/include/HybridPublic/SentryAppStartMeasurement.h @@ -1,5 +1,7 @@ #import "PrivatesHeader.h" +#if SENTRY_HAS_UIKIT + NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(NSUInteger, SentryAppStartType) { @@ -71,3 +73,5 @@ SENTRY_NO_INIT @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/HybridPublic/SentryScreenFrames.h b/Sources/Sentry/include/HybridPublic/SentryScreenFrames.h index e113a6dccc4..f6b3709f811 100644 --- a/Sources/Sentry/include/HybridPublic/SentryScreenFrames.h +++ b/Sources/Sentry/include/HybridPublic/SentryScreenFrames.h @@ -1,9 +1,9 @@ #import "PrivatesHeader.h" -NS_ASSUME_NONNULL_BEGIN - #if SENTRY_HAS_UIKIT +NS_ASSUME_NONNULL_BEGIN + /** An array of dictionaries that each contain a start and end timestamp for a rendered frame. */ # if SENTRY_TARGET_PROFILING_SUPPORTED typedef NSArray *> SentryFrameInfoTimeSeries; @@ -53,6 +53,6 @@ SENTRY_NO_INIT @end -#endif - NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryAppStartTracker.h b/Sources/Sentry/include/SentryAppStartTracker.h index 461fe5d58ec..be808ea0c0f 100644 --- a/Sources/Sentry/include/SentryAppStartTracker.h +++ b/Sources/Sentry/include/SentryAppStartTracker.h @@ -1,12 +1,13 @@ -#import "SentryCurrentDateProvider.h" #import "SentryDefines.h" +#if SENTRY_HAS_UIKIT + +# import "SentryCurrentDateProvider.h" + @class SentryDispatchQueueWrapper, SentryAppStateManager, SentrySysctl; NS_ASSUME_NONNULL_BEGIN -#if SENTRY_HAS_UIKIT - /** * Tracks cold and warm app start time for iOS, tvOS, and Mac Catalyst. The logic for the different * app start types is based on https://developer.apple.com/videos/play/wwdc2019/423/. Cold start: @@ -29,6 +30,6 @@ SENTRY_NO_INIT @end -#endif - NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryAppStartTrackingIntegration.h b/Sources/Sentry/include/SentryAppStartTrackingIntegration.h index a3eaed82201..858eccfd655 100644 --- a/Sources/Sentry/include/SentryAppStartTrackingIntegration.h +++ b/Sources/Sentry/include/SentryAppStartTrackingIntegration.h @@ -1,6 +1,10 @@ -#import "SentryBaseIntegration.h" -#import "SentryIntegrationProtocol.h" -#import +#import "SentryDefines.h" + +#if SENTRY_HAS_UIKIT + +# import "SentryBaseIntegration.h" +# import "SentryIntegrationProtocol.h" +# import NS_ASSUME_NONNULL_BEGIN @@ -14,3 +18,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryDependencyContainer.h b/Sources/Sentry/include/SentryDependencyContainer.h index 4d7ce07cbc9..96d39ec0f29 100644 --- a/Sources/Sentry/include/SentryDependencyContainer.h +++ b/Sources/Sentry/include/SentryDependencyContainer.h @@ -8,7 +8,6 @@ @class SentryDebugImageProvider; @class SentryDispatchFactory; @class SentryDispatchQueueWrapper; -@class SentryFramesTracker; @class SentryMXManager; @class SentryNSNotificationCenterWrapper; @class SentryNSProcessInfoWrapper; @@ -18,6 +17,7 @@ @class SentryThreadWrapper; #if SENTRY_HAS_UIKIT +@class SentryFramesTracker; @class SentryScreenshot; @class SentryUIApplication; @class SentryViewHierarchy; diff --git a/Sources/Sentry/include/SentryDisplayLinkWrapper.h b/Sources/Sentry/include/SentryDisplayLinkWrapper.h index 99e55f9bb13..4ad510b7c2e 100644 --- a/Sources/Sentry/include/SentryDisplayLinkWrapper.h +++ b/Sources/Sentry/include/SentryDisplayLinkWrapper.h @@ -1,9 +1,9 @@ #import "SentryDefines.h" -NS_ASSUME_NONNULL_BEGIN - #if SENTRY_HAS_UIKIT +NS_ASSUME_NONNULL_BEGIN + /** * A wrapper around DisplayLink for testability. */ @@ -19,6 +19,6 @@ NS_ASSUME_NONNULL_BEGIN @end -#endif - NS_ASSUME_NONNULL_END + +#endif // diff --git a/Sources/Sentry/include/SentryDisplayLinkWrapper.m b/Sources/Sentry/include/SentryDisplayLinkWrapper.m index 48bdc3ea100..dc7a2bd8469 100644 --- a/Sources/Sentry/include/SentryDisplayLinkWrapper.m +++ b/Sources/Sentry/include/SentryDisplayLinkWrapper.m @@ -1,6 +1,7 @@ #import "SentryDisplayLinkWrapper.h" #if SENTRY_HAS_UIKIT + # import @implementation SentryDisplayLinkWrapper { @@ -30,4 +31,4 @@ - (void)invalidate @end -#endif +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryFramesTracker.h b/Sources/Sentry/include/SentryFramesTracker.h index 84de4388493..6724c3562c6 100644 --- a/Sources/Sentry/include/SentryFramesTracker.h +++ b/Sources/Sentry/include/SentryFramesTracker.h @@ -1,12 +1,13 @@ #import "SentryDefines.h" -#import "SentryProfilingConditionals.h" + +#if SENTRY_HAS_UIKIT + +# import "SentryProfilingConditionals.h" @class SentryOptions, SentryDisplayLinkWrapper, SentryScreenFrames; NS_ASSUME_NONNULL_BEGIN -#if SENTRY_HAS_UIKIT - @class SentryTracer; @protocol SentryFramesTrackerListener @@ -39,6 +40,6 @@ NS_ASSUME_NONNULL_BEGIN @end -#endif - NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryFramesTrackingIntegration.h b/Sources/Sentry/include/SentryFramesTrackingIntegration.h index 2d16fe0deb9..67172bf36d4 100644 --- a/Sources/Sentry/include/SentryFramesTrackingIntegration.h +++ b/Sources/Sentry/include/SentryFramesTrackingIntegration.h @@ -1,6 +1,10 @@ -#import "SentryBaseIntegration.h" -#import "SentryIntegrationProtocol.h" -#import +#import "SentryDefines.h" + +#if SENTRY_HAS_UIKIT + +# import "SentryBaseIntegration.h" +# import "SentryIntegrationProtocol.h" +# import NS_ASSUME_NONNULL_BEGIN @@ -11,3 +15,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryPerformanceTrackingIntegration.h b/Sources/Sentry/include/SentryPerformanceTrackingIntegration.h index 4c9861d406d..2b756977a06 100644 --- a/Sources/Sentry/include/SentryPerformanceTrackingIntegration.h +++ b/Sources/Sentry/include/SentryPerformanceTrackingIntegration.h @@ -1,6 +1,10 @@ -#import "SentryBaseIntegration.h" -#import "SentryIntegrationProtocol.h" -#import +#import "SentryDefines.h" + +#if SENTRY_HAS_UIKIT + +# import "SentryBaseIntegration.h" +# import "SentryIntegrationProtocol.h" +# import NS_ASSUME_NONNULL_BEGIN @@ -14,3 +18,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryScreenshot.h b/Sources/Sentry/include/SentryScreenshot.h index 42e9c2f16bf..a5ce0a5b63d 100644 --- a/Sources/Sentry/include/SentryScreenshot.h +++ b/Sources/Sentry/include/SentryScreenshot.h @@ -24,4 +24,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END -#endif + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryScreenshotIntegration.h b/Sources/Sentry/include/SentryScreenshotIntegration.h index 8280c86c965..43984436b4c 100644 --- a/Sources/Sentry/include/SentryScreenshotIntegration.h +++ b/Sources/Sentry/include/SentryScreenshotIntegration.h @@ -1,17 +1,20 @@ -#import "SentryBaseIntegration.h" -#import "SentryClient+Private.h" -#import "SentryIntegrationProtocol.h" -#import "SentryScreenshot.h" -#import +#import "SentryDefines.h" -NS_ASSUME_NONNULL_BEGIN #if SENTRY_HAS_UIKIT +# import "SentryBaseIntegration.h" +# import "SentryClient+Private.h" +# import "SentryIntegrationProtocol.h" +# import "SentryScreenshot.h" +# import + +NS_ASSUME_NONNULL_BEGIN + @interface SentryScreenshotIntegration : SentryBaseIntegration @end -#endif - NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentrySessionCrashedHandler.h b/Sources/Sentry/include/SentrySessionCrashedHandler.h index fadba4d4c5e..d4cf1c34d80 100644 --- a/Sources/Sentry/include/SentrySessionCrashedHandler.h +++ b/Sources/Sentry/include/SentrySessionCrashedHandler.h @@ -1,11 +1,19 @@ +#import "SentryDefines.h" #import -@class SentryCrashWrapper, SentryDispatchQueueWrapper, SentryWatchdogTerminationLogic; +@class SentryCrashWrapper, SentryDispatchQueueWrapper; +#if SENTRY_HAS_UIKIT +@class SentryWatchdogTerminationLogic; +#endif // SENTRY_HAS_UIKIT @interface SentrySessionCrashedHandler : NSObject +#if SENTRY_HAS_UIKIT - (instancetype)initWithCrashWrapper:(SentryCrashWrapper *)crashWrapper watchdogTerminationLogic:(SentryWatchdogTerminationLogic *)watchdogTerminationLogic; +#else +- (instancetype)initWithCrashWrapper:(SentryCrashWrapper *)crashWrapper; +#endif // SENTRY_HAS_UIKIT /** * When a crash happened the current session is ended as crashed, stored at a different diff --git a/Sources/Sentry/include/SentryTimeToDisplayTracker.h b/Sources/Sentry/include/SentryTimeToDisplayTracker.h index f1d779f40a7..738ffea8e5f 100644 --- a/Sources/Sentry/include/SentryTimeToDisplayTracker.h +++ b/Sources/Sentry/include/SentryTimeToDisplayTracker.h @@ -1,7 +1,7 @@ #import "SentryDefines.h" -#import #if SENTRY_HAS_UIKIT + # import @class SentrySpan; diff --git a/Sources/Sentry/include/SentryUIApplication.h b/Sources/Sentry/include/SentryUIApplication.h index f32d18ed4ba..7ee9b5409df 100644 --- a/Sources/Sentry/include/SentryUIApplication.h +++ b/Sources/Sentry/include/SentryUIApplication.h @@ -1,6 +1,7 @@ #import "SentryDefines.h" #if SENTRY_HAS_UIKIT + # import NS_ASSUME_NONNULL_BEGIN @@ -33,4 +34,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END -#endif + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryUIEventTracker.h b/Sources/Sentry/include/SentryUIEventTracker.h index 941746fde00..23db6f171fd 100644 --- a/Sources/Sentry/include/SentryUIEventTracker.h +++ b/Sources/Sentry/include/SentryUIEventTracker.h @@ -1,5 +1,7 @@ #import "SentryDefines.h" +#if SENTRY_HAS_UIKIT + NS_ASSUME_NONNULL_BEGIN @class SentrySwizzleWrapper, SentryDispatchQueueWrapper; @@ -7,8 +9,6 @@ NS_ASSUME_NONNULL_BEGIN @interface SentryUIEventTracker : NSObject SENTRY_NO_INIT -#if SENTRY_HAS_UIKIT - - (instancetype)initWithSwizzleWrapper:(SentrySwizzleWrapper *)swizzleWrapper dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper idleTimeout:(NSTimeInterval)idleTimeout; @@ -16,10 +16,10 @@ SENTRY_NO_INIT - (void)start; - (void)stop; -#endif - + (BOOL)isUIEventOperation:(NSString *)operation; @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryUIEventTrackingIntegration.h b/Sources/Sentry/include/SentryUIEventTrackingIntegration.h index 098486701d7..c29e2362737 100644 --- a/Sources/Sentry/include/SentryUIEventTrackingIntegration.h +++ b/Sources/Sentry/include/SentryUIEventTrackingIntegration.h @@ -1,11 +1,12 @@ -#import "SentryBaseIntegration.h" -#import "SentryIntegrationProtocol.h" -#import +#import "SentryDefines.h" -NS_ASSUME_NONNULL_BEGIN #if SENTRY_HAS_UIKIT + +# import "SentryBaseIntegration.h" +# import "SentryIntegrationProtocol.h" + @interface SentryUIEventTrackingIntegration : SentryBaseIntegration @end -#endif -NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryUIViewControllerPerformanceTracker.h b/Sources/Sentry/include/SentryUIViewControllerPerformanceTracker.h index 54c8382092f..d0f94f5039c 100644 --- a/Sources/Sentry/include/SentryUIViewControllerPerformanceTracker.h +++ b/Sources/Sentry/include/SentryUIViewControllerPerformanceTracker.h @@ -1,7 +1,7 @@ #import "SentryDefines.h" -#import #if SENTRY_HAS_UIKIT + # import @class SentrySpan, SentryInAppLogic; @@ -104,4 +104,5 @@ static NSString *const SENTRY_UI_PERFORMANCE_TRACKER_TTD_TRACKER @end NS_ASSUME_NONNULL_END + #endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryUIViewControllerSwizzling.h b/Sources/Sentry/include/SentryUIViewControllerSwizzling.h index 0115ad7af44..dedf2fa5c35 100644 --- a/Sources/Sentry/include/SentryUIViewControllerSwizzling.h +++ b/Sources/Sentry/include/SentryUIViewControllerSwizzling.h @@ -1,8 +1,8 @@ #import "SentryDefines.h" -#import "SentryObjCRuntimeWrapper.h" -#import #if SENTRY_HAS_UIKIT + +# import "SentryObjCRuntimeWrapper.h" # import NS_ASSUME_NONNULL_BEGIN @@ -35,6 +35,7 @@ SENTRY_NO_INIT - (void)start; @end + NS_ASSUME_NONNULL_END -#endif +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryViewHierarchyIntegration.h b/Sources/Sentry/include/SentryViewHierarchyIntegration.h index 164b0b46c2f..7d32e2a3f7c 100644 --- a/Sources/Sentry/include/SentryViewHierarchyIntegration.h +++ b/Sources/Sentry/include/SentryViewHierarchyIntegration.h @@ -1,16 +1,19 @@ -#import "SentryBaseIntegration.h" -#import "SentryClient+Private.h" -#import "SentryIntegrationProtocol.h" -#import +#import "SentryDefines.h" -NS_ASSUME_NONNULL_BEGIN #if SENTRY_HAS_UIKIT +# import "SentryBaseIntegration.h" +# import "SentryClient+Private.h" +# import "SentryIntegrationProtocol.h" +# import + +NS_ASSUME_NONNULL_BEGIN + @interface SentryViewHierarchyIntegration : SentryBaseIntegration @end -#endif - NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryWatchdogTerminationLogic.h b/Sources/Sentry/include/SentryWatchdogTerminationLogic.h index c80a6546932..7144b0653bc 100644 --- a/Sources/Sentry/include/SentryWatchdogTerminationLogic.h +++ b/Sources/Sentry/include/SentryWatchdogTerminationLogic.h @@ -1,5 +1,7 @@ #import "SentryDefines.h" +#if SENTRY_HAS_UIKIT + @class SentryOptions, SentryCrashWrapper, SentryAppState, SentryFileManager, SentryAppStateManager; NS_ASSUME_NONNULL_BEGIN @@ -16,3 +18,5 @@ SENTRY_NO_INIT @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryWatchdogTerminationScopeObserver.h b/Sources/Sentry/include/SentryWatchdogTerminationScopeObserver.h index f5b5f617c17..52ad76d13fd 100644 --- a/Sources/Sentry/include/SentryWatchdogTerminationScopeObserver.h +++ b/Sources/Sentry/include/SentryWatchdogTerminationScopeObserver.h @@ -1,5 +1,8 @@ #import "SentryDefines.h" -#import "SentryScopeObserver.h" + +#if SENTRY_HAS_UIKIT + +# import "SentryScopeObserver.h" @class SentryFileManager; @@ -20,3 +23,5 @@ SENTRY_NO_INIT @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryWatchdogTerminationTrackingIntegration.h b/Sources/Sentry/include/SentryWatchdogTerminationTrackingIntegration.h index 718b112cf7e..90997a3ab02 100644 --- a/Sources/Sentry/include/SentryWatchdogTerminationTrackingIntegration.h +++ b/Sources/Sentry/include/SentryWatchdogTerminationTrackingIntegration.h @@ -1,7 +1,11 @@ -#import "SentryANRTracker.h" -#import "SentryBaseIntegration.h" -#import "SentryIntegrationProtocol.h" -#import +#import "SentryDefines.h" + +#if SENTRY_HAS_UIKIT + +# import "SentryANRTracker.h" +# import "SentryBaseIntegration.h" +# import "SentryIntegrationProtocol.h" +# import NS_ASSUME_NONNULL_BEGIN @@ -11,3 +15,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Tests/SentryProfilerTests/SentryProfilerSwiftTests.swift b/Tests/SentryProfilerTests/SentryProfilerSwiftTests.swift index b84a9b9f4cc..a82a75bf023 100644 --- a/Tests/SentryProfilerTests/SentryProfilerSwiftTests.swift +++ b/Tests/SentryProfilerTests/SentryProfilerSwiftTests.swift @@ -192,6 +192,7 @@ class SentryProfilerSwiftTests: XCTestCase { var appStartDuration = 0.5 lazy var appStartEnd = appStart.addingTimeInterval(appStartDuration) + #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func getAppStartMeasurement(type: SentryAppStartType, preWarmed: Bool = false) -> SentryAppStartMeasurement { let runtimeInitDuration = 0.05 let runtimeInit = appStart.addingTimeInterval(runtimeInitDuration) @@ -203,6 +204,7 @@ class SentryProfilerSwiftTests: XCTestCase { appStartEnd = appStart.addingTimeInterval(appStartDuration) return SentryAppStartMeasurement(type: type, isPreWarmed: preWarmed, appStartTimestamp: appStart, duration: appStartDuration, runtimeInitTimestamp: runtimeInit, moduleInitializationTimestamp: main, didFinishLaunchingTimestamp: didFinishLaunching) } + #endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) } private var fixture: Fixture! @@ -323,17 +325,19 @@ class SentryProfilerSwiftTests: XCTestCase { try performTest(transactionEnvironment: expectedEnvironment) } + #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func testProfileWithTransactionContainingStartupSpansForColdStart() throws { - try performTest(launchType: .cold, prewarmed: false) + try performTest(uikitParameters: UIKitParameters(launchType: .cold, prewarmed: false)) } func testProfileWithTransactionContainingStartupSpansForWarmStart() throws { - try performTest(launchType: .warm, prewarmed: false) + try performTest(uikitParameters: UIKitParameters(launchType: .warm, prewarmed: false)) } func testProfileWithTransactionContainingStartupSpansForPrewarmedStart() throws { - try performTest(launchType: .cold, prewarmed: true) + try performTest(uikitParameters: UIKitParameters(launchType: .cold, prewarmed: true)) } +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func testProfilingDataContainsEnvironmentSetFromConfigureScope() throws { let expectedEnvironment = "test-environment" @@ -419,13 +423,23 @@ private extension SentryProfilerSwiftTests { SentryProfilerMocksSwiftCompatible.appendMockBacktrace(to: state, threadID: threadMetadata.id, threadPriority: threadMetadata.priority, threadName: threadMetadata.name, queueAddress: queueMetadata.address, queueLabel: queueMetadata.label, addresses: addresses) } - func performTest(transactionEnvironment: String = kSentryDefaultEnvironment, shouldTimeOut: Bool = false, launchType: SentryAppStartType? = nil, prewarmed: Bool = false) throws { + struct UIKitParameters { + #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + var launchType: SentryAppStartType + var prewarmed: Bool + #endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + } + + func performTest(transactionEnvironment: String = kSentryDefaultEnvironment, shouldTimeOut: Bool = false, uikitParameters: UIKitParameters? = nil) throws { var testingAppLaunchSpans = false - if let launchType = launchType { + + #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + if let uikitParameters = uikitParameters { testingAppLaunchSpans = true - let appStartMeasurement = fixture.getAppStartMeasurement(type: launchType, preWarmed: prewarmed) + let appStartMeasurement = fixture.getAppStartMeasurement(type: uikitParameters.launchType, preWarmed: uikitParameters.prewarmed) SentrySDK.setAppStartMeasurement(appStartMeasurement) } +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) let span = try fixture.newTransaction(testingAppLaunchSpans: testingAppLaunchSpans) diff --git a/Tests/SentryTests/Helper/SentryFileManagerTests.swift b/Tests/SentryTests/Helper/SentryFileManagerTests.swift index 2fec5c2477a..8d3812e05c3 100644 --- a/Tests/SentryTests/Helper/SentryFileManagerTests.swift +++ b/Tests/SentryTests/Helper/SentryFileManagerTests.swift @@ -576,6 +576,8 @@ class SentryFileManagerTests: XCTestCase { XCTAssertNotNil(sut.readTimezoneOffset()) } + #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + func testReadPreviousBreadcrumbs() { let observer = SentryWatchdogTerminationScopeObserver(maxBreadcrumbs: 2, fileManager: sut) @@ -614,6 +616,8 @@ class SentryFileManagerTests: XCTestCase { XCTAssertEqual((result[2] as! NSDictionary)["message"] as! String, "4") } +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + func testReadGarbageTimezoneOffset() throws { try "garbage".write(to: URL(fileURLWithPath: sut.timezoneOffsetFilePath), atomically: true, encoding: .utf8) XCTAssertNil(sut.readTimezoneOffset()) diff --git a/Tests/SentryTests/Integrations/Performance/FramesTracking/SentryFramesTracker+TestInit.h b/Tests/SentryTests/Integrations/Performance/FramesTracking/SentryFramesTracker+TestInit.h index 682921307ba..7b556aa6c78 100644 --- a/Tests/SentryTests/Integrations/Performance/FramesTracking/SentryFramesTracker+TestInit.h +++ b/Tests/SentryTests/Integrations/Performance/FramesTracking/SentryFramesTracker+TestInit.h @@ -1,9 +1,11 @@ #import "SentryDefines.h" -#import "SentryFramesTracker.h" + +#if SENTRY_HAS_UIKIT + +# import "SentryFramesTracker.h" NS_ASSUME_NONNULL_BEGIN -#if SENTRY_HAS_UIKIT SENTRY_EXTERN double slowFrameThreshold(uint64_t actualFramesPerSecond); SENTRY_EXTERN CFTimeInterval const SentryFrozenFrameThreshold; @@ -17,6 +19,7 @@ SentryFramesTracker (TestInit) - (void)resetFrames; @end -#endif NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Tests/SentryTests/Integrations/Performance/SentryPerformanceTrackerTests.swift b/Tests/SentryTests/Integrations/Performance/SentryPerformanceTrackerTests.swift index c483faec6f1..599fca34499 100644 --- a/Tests/SentryTests/Integrations/Performance/SentryPerformanceTrackerTests.swift +++ b/Tests/SentryTests/Integrations/Performance/SentryPerformanceTrackerTests.swift @@ -66,7 +66,8 @@ class SentryPerformanceTrackerTests: XCTestCase { XCTAssert(scopeSpan !== transaction) XCTAssert(scopeSpan === firstTransaction) } - + +#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func testStartSpan_ScopeWithUIActionSpan_FinishesSpan() { let sut = fixture.getSut() let firstTransaction = SentrySDK.startTransaction(name: fixture.someTransaction, operation: "ui.action", bindToScope: true) @@ -80,6 +81,7 @@ class SentryPerformanceTrackerTests: XCTestCase { XCTAssertTrue(firstTransaction.isFinished) XCTAssertEqual(.cancelled, firstTransaction.status) } +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func testStartSpan_WithActiveSpan() { let sut = fixture.getSut() diff --git a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryTimeToDisplayTrackerTest.swift b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryTimeToDisplayTrackerTest.swift index 64cf8b5f3d0..c849b6cd898 100644 --- a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryTimeToDisplayTrackerTest.swift +++ b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryTimeToDisplayTrackerTest.swift @@ -276,4 +276,4 @@ class SentryTimeToDisplayTrackerTest: XCTestCase { } } -#endif +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) diff --git a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerPerformanceTrackerTests.swift b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerPerformanceTrackerTests.swift index 0c06cfd4b05..1f8b5d22680 100644 --- a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerPerformanceTrackerTests.swift +++ b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerPerformanceTrackerTests.swift @@ -1,9 +1,9 @@ +#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + import ObjectiveC import SentryTestUtils import XCTest -#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) - class TestViewController: UIViewController { } @@ -624,4 +624,4 @@ class SentryUIViewControllerPerformanceTrackerTests: XCTestCase { Dynamic(SentryDependencyContainer.sharedInstance().framesTracker).displayLinkCallback() } } -#endif +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) diff --git a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzling+Test.h b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzling+Test.h index 19ace62396b..b912d30505b 100644 --- a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzling+Test.h +++ b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzling+Test.h @@ -1,8 +1,8 @@ -#import "SentryUIViewControllerSwizzling.h" +#if SENTRY_HAS_UIKIT -NS_ASSUME_NONNULL_BEGIN +# import "SentryUIViewControllerSwizzling.h" -#if SENTRY_HAS_UIKIT +NS_ASSUME_NONNULL_BEGIN @interface SentryUIViewControllerSwizzling (Test) @@ -24,6 +24,6 @@ SentryUIViewControllerSwizzling (Test) - (void)swizzleUIViewControllersOfImage:(NSString *)imageName; @end -#endif - NS_ASSUME_NONNULL_END + +#endif // SENTRY_HAS_UIKIT diff --git a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift index f159e4e24e6..1b306ec7bde 100644 --- a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift +++ b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift @@ -1,8 +1,9 @@ +#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + import Sentry import SentryTestUtils import XCTest -#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) class SentryUIViewControllerSwizzlingTests: XCTestCase { private class Fixture { @@ -335,4 +336,4 @@ class TestSubClassFinder: SentrySubClassFinder { } } -#endif +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) diff --git a/Tests/SentryTests/Integrations/Screenshot/SentryScreenshotIntegrationTests.swift b/Tests/SentryTests/Integrations/Screenshot/SentryScreenshotIntegrationTests.swift index d35a11e3f25..488d6d24edc 100644 --- a/Tests/SentryTests/Integrations/Screenshot/SentryScreenshotIntegrationTests.swift +++ b/Tests/SentryTests/Integrations/Screenshot/SentryScreenshotIntegrationTests.swift @@ -1,8 +1,9 @@ +#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + import Sentry import SentryTestUtils import XCTest -#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) class SentryScreenshotIntegrationTests: XCTestCase { private class Fixture { @@ -160,4 +161,5 @@ class SentryScreenshotIntegrationTests: XCTestCase { } } -#endif + +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) diff --git a/Tests/SentryTests/Integrations/Screenshot/TestSentryScreenShot.swift b/Tests/SentryTests/Integrations/Screenshot/TestSentryScreenShot.swift index 5e61435e5c7..9dce11b464a 100644 --- a/Tests/SentryTests/Integrations/Screenshot/TestSentryScreenShot.swift +++ b/Tests/SentryTests/Integrations/Screenshot/TestSentryScreenShot.swift @@ -1,6 +1,5 @@ -import Foundation - #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + class TestSentryScreenshot: SentryScreenshot { var result: [Data]? @@ -10,4 +9,5 @@ class TestSentryScreenshot: SentryScreenshot { } } -#endif + +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) diff --git a/Tests/SentryTests/Integrations/ViewHierarchy/SentryViewHierarchyIntegrationTests.swift b/Tests/SentryTests/Integrations/ViewHierarchy/SentryViewHierarchyIntegrationTests.swift index e157894146a..1460a2da18c 100644 --- a/Tests/SentryTests/Integrations/ViewHierarchy/SentryViewHierarchyIntegrationTests.swift +++ b/Tests/SentryTests/Integrations/ViewHierarchy/SentryViewHierarchyIntegrationTests.swift @@ -1,8 +1,9 @@ +#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + import Sentry import SentryTestUtils import XCTest -#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) class SentryViewHierarchyIntegrationTests: XCTestCase { private class Fixture { @@ -109,4 +110,5 @@ class SentryViewHierarchyIntegrationTests: XCTestCase { XCTAssertEqual(newAttachmentList?.first, attachment) } } -#endif + +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) diff --git a/Tests/SentryTests/Integrations/ViewHierarchy/TestSentryViewHierarchy.h b/Tests/SentryTests/Integrations/ViewHierarchy/TestSentryViewHierarchy.h index 9f5ded4a116..a6989838f7f 100644 --- a/Tests/SentryTests/Integrations/ViewHierarchy/TestSentryViewHierarchy.h +++ b/Tests/SentryTests/Integrations/ViewHierarchy/TestSentryViewHierarchy.h @@ -1,9 +1,10 @@ -#import "SentryCrashJSONCodec.h" #import "SentryDefines.h" -#import "SentryViewHierarchy.h" #if SENTRY_HAS_UIKIT +# import "SentryCrashJSONCodec.h" +# import "SentryViewHierarchy.h" + void saveViewHierarchy(const char *path); @interface @@ -13,4 +14,5 @@ SentryViewHierarchy (Test) addFunction:(SentryCrashJSONAddDataFunc)addJSONDataFunc userData:(void *const)userData; @end -#endif + +#endif // SENTRY_HAS_UIKIT diff --git a/Tests/SentryTests/Integrations/ViewHierarchy/TestSentryViewHierarchy.swift b/Tests/SentryTests/Integrations/ViewHierarchy/TestSentryViewHierarchy.swift index 02d2d60e93e..a49d965db92 100644 --- a/Tests/SentryTests/Integrations/ViewHierarchy/TestSentryViewHierarchy.swift +++ b/Tests/SentryTests/Integrations/ViewHierarchy/TestSentryViewHierarchy.swift @@ -1,6 +1,5 @@ -import Foundation - #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + class TestSentryViewHierarchy: SentryViewHierarchy { var result: Data? @@ -30,4 +29,4 @@ class TestSentryViewHierarchy: SentryViewHierarchy { return super .processViewHierarchy(windows, add: addJSONDataFunc, userData: userData) } } -#endif +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) diff --git a/Tests/SentryTests/Integrations/WatchdogTerminations/SentryWatchdogTerminationsIntegrationTests.swift b/Tests/SentryTests/Integrations/WatchdogTerminations/SentryWatchdogTerminationsIntegrationTests.swift index 1bae051838d..733d3d5011c 100644 --- a/Tests/SentryTests/Integrations/WatchdogTerminations/SentryWatchdogTerminationsIntegrationTests.swift +++ b/Tests/SentryTests/Integrations/WatchdogTerminations/SentryWatchdogTerminationsIntegrationTests.swift @@ -1,3 +1,5 @@ +#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + import SentryTestUtils import XCTest @@ -123,3 +125,5 @@ class SentryWatchdogTerminationIntegrationTests: XCTestCase { } } + +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) diff --git a/Tests/SentryTests/Integrations/WatchdogTerminations/SentryWatchdogTerminationsScopeObserverTests.swift b/Tests/SentryTests/Integrations/WatchdogTerminations/SentryWatchdogTerminationsScopeObserverTests.swift index 840dbb2b5dc..56bf5975e4e 100644 --- a/Tests/SentryTests/Integrations/WatchdogTerminations/SentryWatchdogTerminationsScopeObserverTests.swift +++ b/Tests/SentryTests/Integrations/WatchdogTerminations/SentryWatchdogTerminationsScopeObserverTests.swift @@ -1,3 +1,5 @@ +#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + import SentryTestUtils import XCTest @@ -154,3 +156,5 @@ class SentryWatchdogTerminationScopeObserverTests: XCTestCase { XCTAssertEqual(1, fixture.fileManager.readPreviousBreadcrumbs().count) } } + +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) diff --git a/Tests/SentryTests/PrivateSentrySDKOnlyTests.swift b/Tests/SentryTests/PrivateSentrySDKOnlyTests.swift index c7a17b00d99..c1fd7867864 100644 --- a/Tests/SentryTests/PrivateSentrySDKOnlyTests.swift +++ b/Tests/SentryTests/PrivateSentrySDKOnlyTests.swift @@ -81,7 +81,8 @@ class PrivateSentrySDKOnlyTests: XCTestCase { // SentryDebugImageProviderTests XCTAssertGreaterThan(images.count, 100) } - + +#if SENTRY_HAS_UIKIT func testGetAppStartMeasurement() { let appStartMeasurement = TestData.getAppStartMeasurement(type: .warm) SentrySDK.setAppStartMeasurement(appStartMeasurement) @@ -91,7 +92,8 @@ class PrivateSentrySDKOnlyTests: XCTestCase { SentrySDK.setAppStartMeasurement(nil) XCTAssertNil(PrivateSentrySDKOnly.appStartMeasurement) } - +#endif // SENTRY_HAS_UIKIT + func testGetInstallationId() { XCTAssertEqual(SentryInstallation.id(), PrivateSentrySDKOnly.installationID) } diff --git a/Tests/SentryTests/Protocol/TestData.swift b/Tests/SentryTests/Protocol/TestData.swift index dd8a9f29308..e9c7b365f5c 100644 --- a/Tests/SentryTests/Protocol/TestData.swift +++ b/Tests/SentryTests/Protocol/TestData.swift @@ -317,7 +317,9 @@ class TestData { return request } - + + #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + static func getAppStartMeasurement(type: SentryAppStartType, appStartTimestamp: Date = TestData.timestamp) -> SentryAppStartMeasurement { let appStartDuration = 0.5 let main = appStartTimestamp.addingTimeInterval(0.15) @@ -327,4 +329,5 @@ class TestData { return SentryAppStartMeasurement(type: type, isPreWarmed: false, appStartTimestamp: appStartTimestamp, duration: appStartDuration, runtimeInitTimestamp: runtimeInit, moduleInitializationTimestamp: main, didFinishLaunchingTimestamp: didFinishLaunching) } + #endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) } diff --git a/Tests/SentryTests/SentrySDKTests.swift b/Tests/SentryTests/SentrySDKTests.swift index 4bc5bca8df0..bd07f115d64 100644 --- a/Tests/SentryTests/SentrySDKTests.swift +++ b/Tests/SentryTests/SentrySDKTests.swift @@ -463,7 +463,8 @@ class SentrySDKTests: XCTestCase { SentrySDK.setCurrentHub(fixture.hub) XCTAssertEqual(SentrySDK.options, fixture.options) } - + +#if SENTRY_HAS_UIKIT func testSetAppStartMeasurement_CallsPrivateSDKCallback() { let appStartMeasurement = TestData.getAppStartMeasurement(type: .warm) @@ -484,6 +485,7 @@ class SentrySDKTests: XCTestCase { XCTAssertEqual(SentrySDK.getAppStartMeasurement(), appStartMeasurement) } +#endif // SENTRY_HAS_UIKIT func testSDKStartInvocations() { XCTAssertEqual(0, SentrySDK.startInvocations) @@ -636,6 +638,8 @@ class SentrySDKTests: XCTestCase { XCTAssertEqual(flushTimeout, transport.flushInvocations.first) } +#if SENTRY_HAS_UIKIT + func testSetAppStartMeasurementConcurrently() { func setAppStartMeasurement(_ queue: DispatchQueue, _ i: Int) { group.enter() @@ -646,26 +650,26 @@ class SentrySDKTests: XCTestCase { group.leave() } } - + func createQueue() -> DispatchQueue { return DispatchQueue(label: "SentrySDKTests", qos: .userInteractive, attributes: [.initiallyInactive]) } - + let queue1 = createQueue() let queue2 = createQueue() let group = DispatchGroup() - + let amount = 100 - + for i in 0...amount { setAppStartMeasurement(queue1, i) setAppStartMeasurement(queue2, i) } - + queue1.activate() queue2.activate() group.waitWithTimeout(timeout: 100) - + let timestamp = self.fixture.currentDate.date().addingTimeInterval(TimeInterval(amount)) XCTAssertEqual(timestamp, SentrySDK.getAppStartMeasurement()?.appStartTimestamp) } @@ -687,7 +691,9 @@ class SentrySDKTests: XCTestCase { let result = fileManager.readPreviousBreadcrumbs() XCTAssertEqual(result.count, 3) } - + +#endif // SENTRY_HAS_UIKIT + private func givenSdkWithHub() { SentrySDK.setCurrentHub(fixture.hub) } diff --git a/Tests/SentryTests/SentryTests-Bridging-Header.h b/Tests/SentryTests/SentryTests-Bridging-Header.h index a8e7460efa0..a60ea29375c 100644 --- a/Tests/SentryTests/SentryTests-Bridging-Header.h +++ b/Tests/SentryTests/SentryTests-Bridging-Header.h @@ -1,7 +1,17 @@ -// -// Use this file to import your target's public headers that you would like to -// expose to Swift. -// +#import "SentryDefines.h" + +#if SENTRY_HAS_UIKIT +# import "MockUIScene.h" +# import "SentryFramesTracker+TestInit.h" +# import "SentryUIApplication.h" +# import "SentryUIDeviceWrapper.h" +# import "SentryUIEventTracker.h" +# import "SentryUIEventTrackingIntegration.h" +# import "SentryUIViewControllerPerformanceTracker.h" +# import "SentryUIViewControllerSwizzling+Test.h" +# import "SentryUIViewControllerSwizzling.h" +#endif // SENTRY_HAS_UIKIT + #import "NSData+Sentry.h" #import "NSData+SentryCompression.h" #import "NSDate+SentryExtras.h" @@ -83,8 +93,6 @@ #import "SentryFormatter.h" #import "SentryFrame.h" #import "SentryFrameRemover.h" -#import "SentryFramesTracker+TestInit.h" -#import "SentryFramesTracker.h" #import "SentryFramesTrackingIntegration.h" #import "SentryGlobalEventProcessor.h" #import "SentryHttpDateParser.h" @@ -169,11 +177,6 @@ #import "SentryTransport.h" #import "SentryTransportAdapter.h" #import "SentryTransportFactory.h" -#import "SentryUIApplication.h" -#import "SentryUIDeviceWrapper.h" -#import "SentryUIViewControllerPerformanceTracker.h" -#import "SentryUIViewControllerSwizzling+Test.h" -#import "SentryUIViewControllerSwizzling.h" #import "SentryUserFeedback.h" #import "SentryViewHierarchy.h" #import "SentryViewHierarchyIntegration.h" @@ -203,9 +206,3 @@ #import "SentryTimeToDisplayTracker.h" #import "SentryTracerConfiguration.h" #import "TestSentryViewHierarchy.h" -#if SENTRY_HAS_UIKIT -# import "MockUIScene.h" -# import "SentryUIEventTracker.h" -# import "SentryUIEventTrackingIntegration.h" -# import "SentryUIViewControllerPerformanceTracker.h" -#endif diff --git a/Tests/SentryTests/Transaction/SentryTracerTests.swift b/Tests/SentryTests/Transaction/SentryTracerTests.swift index d14443df49c..ed7be4a1793 100644 --- a/Tests/SentryTests/Transaction/SentryTracerTests.swift +++ b/Tests/SentryTests/Transaction/SentryTracerTests.swift @@ -45,7 +45,7 @@ class SentryTracerTests: XCTestCase { #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) var displayLinkWrapper: TestDisplayLinkWrapper -#endif +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) init() { dispatchQueue.blockBeforeMainBlock = { false } @@ -67,9 +67,10 @@ class SentryTracerTests: XCTestCase { SentryDependencyContainer.sharedInstance().framesTracker.setDisplayLinkWrapper(displayLinkWrapper) SentryDependencyContainer.sharedInstance().framesTracker.start() displayLinkWrapper.call() -#endif +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) } - + +#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func getAppStartMeasurement(type: SentryAppStartType, preWarmed: Bool = false) -> SentryAppStartMeasurement { let runtimeInitDuration = 0.05 let runtimeInit = appStart.addingTimeInterval(runtimeInitDuration) @@ -83,6 +84,7 @@ class SentryTracerTests: XCTestCase { return SentryAppStartMeasurement(type: type, isPreWarmed: preWarmed, appStartTimestamp: appStart, duration: appStartDuration, runtimeInitTimestamp: runtimeInit, moduleInitializationTimestamp: main, didFinishLaunchingTimestamp: didFinishLaunching) } + #endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func getSut(waitForChildren: Bool = true) -> SentryTracer { let tracer = hub.startTransaction( @@ -316,7 +318,8 @@ class SentryTracerTests: XCTestCase { assertOneTransactionCaptured(sut) } - + + #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func testFinish_WaitForAllChildren_StartTimeModified_NoTransactionCaptured() { let appStartMeasurement = fixture.getAppStartMeasurement(type: .cold) SentrySDK.setAppStartMeasurement(appStartMeasurement) @@ -329,6 +332,7 @@ class SentryTracerTests: XCTestCase { assertTransactionNotCaptured(sut) } + #endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func testFinish_IdleTimeout_ExceedsMaxDuration_NoTransactionCaptured() { let sut = fixture.getSut(idleTimeout: fixture.idleTimeout, dispatchQueueWrapper: fixture.dispatchQueue) @@ -531,7 +535,8 @@ class SentryTracerTests: XCTestCase { XCTAssertTrue(sut.isFinished) } - + + #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func testAddColdAppStartMeasurement_PutOnNextAutoUITransaction() { let appStartMeasurement = fixture.getAppStartMeasurement(type: .cold) SentrySDK.setAppStartMeasurement(appStartMeasurement) @@ -543,6 +548,7 @@ class SentryTracerTests: XCTestCase { let transaction = fixture.hub.capturedEventsWithScopes.first!.event as! Transaction assertAppStartsSpanAdded(transaction: transaction, startType: "Cold Start", operation: fixture.appStartColdOperation, appStartMeasurement: appStartMeasurement) } + #endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func test_startChildWithDelegate() { let delegate = TracerDelegate() @@ -591,6 +597,8 @@ class SentryTracerTests: XCTestCase { XCTAssertEqual(secondChild.parentSpanId, child.parentSpanId) } + #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + func testAddPreWarmedAppStartMeasurement_PutOnNextAutoUITransaction() { let appStartMeasurement = fixture.getAppStartMeasurement(type: .cold, preWarmed: true) SentrySDK.setAppStartMeasurement(appStartMeasurement) @@ -749,6 +757,8 @@ class SentryTracerTests: XCTestCase { assertAppStartMeasurementNotPutOnTransaction() } + +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func testMeasurementOnChildSpan_SetTwice_OverwritesMeasurement() { let name = "something" @@ -874,7 +884,9 @@ class SentryTracerTests: XCTestCase { let spans = try getSerializedTransaction()["spans"]! as! [[String: Any]] XCTAssertEqual(spans.count, children * (grandchildren + 1) + 1) } - + + #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) + func testConcurrentTransactions_OnlyOneGetsMeasurement() { SentrySDK.setAppStartMeasurement(fixture.getAppStartMeasurement(type: .warm)) @@ -903,6 +915,8 @@ class SentryTracerTests: XCTestCase { XCTAssertEqual(1, transactionsWithAppStartMeasurement.count) } + + #endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) func testAddingSpansOnDifferentThread_WhileFinishing_DoesNotCrash() throws { let sut = fixture.getSut(waitForChildren: false) @@ -1029,7 +1043,8 @@ class SentryTracerTests: XCTestCase { XCTAssertTrue(tracer.isFinished) XCTAssertEqual(1, fixture.hub.capturedEventsWithScopes.count) } - + + #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) private func assertAppStartsSpanAdded(transaction: Transaction, startType: String, operation: String, appStartMeasurement: SentryAppStartMeasurement) { let spans: [SentrySpan]? = Dynamic(transaction).spans XCTAssertEqual(5, spans?.count) @@ -1108,6 +1123,8 @@ class SentryTracerTests: XCTestCase { let spans = serializedTransaction["spans"]! as! [[String: Any]] XCTAssertEqual(0, spans.count) } + +#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) private func assertNoMeasurementsAdded() { XCTAssertEqual(1, fixture.hub.capturedEventsWithScopes.count) diff --git a/scripts/no-changes-in-high-risk-files.sh b/scripts/no-changes-in-high-risk-files.sh index d506ad73b48..f386f5875f3 100755 --- a/scripts/no-changes-in-high-risk-files.sh +++ b/scripts/no-changes-in-high-risk-files.sh @@ -1,12 +1,12 @@ #!/bin/bash -set -euo pipefail +set -euox pipefail # To update the sha run the command in ACTUAL and copy the result in EXPECTED. ACTUAL=$(shasum -a 256 ./Sources/Sentry/SentryNSURLSessionTaskSearch.m ./Sources/Sentry/SentryNetworkTracker.m ./Sources/Sentry/SentryUIViewControllerSwizzling.m ./Sources/Sentry/SentryNSDataSwizzling.m ./Sources/Sentry/SentrySubClassFinder.m ./Sources/Sentry/SentryCoreDataSwizzling.m ./Sources/Sentry/SentrySwizzleWrapper.m ./Sources/Sentry/include/SentrySwizzle.h ./Sources/Sentry/SentrySwizzle.m) EXPECTED="819d5ca5e3db2ac23c859b14c149b7f0754d3ae88bea1dba92c18f49a81da0e1 ./Sources/Sentry/SentryNSURLSessionTaskSearch.m 797f1e4f1f4d0986770c749c6614243417373d3858044a0aa6e16bd4a52533ed ./Sources/Sentry/SentryNetworkTracker.m -52cb473dcc8d13c0d4f6cd1429c3fc6e8588521660b714f4a2edb4eaf1401e9f ./Sources/Sentry/SentryUIViewControllerSwizzling.m +128dee523c75c121e9b8b767d84a2a137e5b60498c9f3ba604aad3c935d780d0 ./Sources/Sentry/SentryUIViewControllerSwizzling.m e95e62ec7363984f20c78643bb7d992a41a740f97e1befb71525ac34caf88b37 ./Sources/Sentry/SentryNSDataSwizzling.m 9ad05dd8dd29788cba994736fdcd3bbde59a94e32612640d11f4f9c38ad6610e ./Sources/Sentry/SentrySubClassFinder.m 13c3030d8c1fb145760d51837773c35127c777fce1d4dbb9009d53d0fcc5dce8 ./Sources/Sentry/SentryCoreDataSwizzling.m