diff --git a/CHANGELOG.md b/CHANGELOG.md index 03a197ca372..54c36334dc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Improvements -- Reduced macOS SDK footprint by 2% (#3157) +- Reduced macOS SDK footprint by 2% (#3157) with similar changes for tvOS and watchOS (#3158, #3159, #3161) ### Fixes diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index 2d189d05689..75e872cc08f 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -887,7 +887,7 @@ 035E73CD27D5790A005EEB11 /* SentryThreadMetadataCacheTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryThreadMetadataCacheTests.mm; sourceTree = ""; }; 03BCC38927E1BF49003232C7 /* SentryTime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryTime.h; path = Sources/Sentry/include/SentryTime.h; sourceTree = SOURCE_ROOT; }; 03BCC38B27E1C01A003232C7 /* SentryTime.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = SentryTime.mm; path = Sources/Sentry/SentryTime.mm; sourceTree = SOURCE_ROOT; }; - 03BCC38D27E2A377003232C7 /* SentryProfilingConditionals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryProfilingConditionals.h; path = Sources/Sentry/Public/SentryProfilingConditionals.h; sourceTree = SOURCE_ROOT; }; + 03BCC38D27E2A377003232C7 /* SentryProfilingConditionals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryProfilingConditionals.h; path = ../Public/SentryProfilingConditionals.h; sourceTree = ""; }; 03F84D1127DD414C008FE43F /* SentryProfiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryProfiler.h; path = Sources/Sentry/include/SentryProfiler.h; sourceTree = SOURCE_ROOT; }; 03F84D1227DD414C008FE43F /* SentryBacktrace.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = SentryBacktrace.hpp; path = Sources/Sentry/include/SentryBacktrace.hpp; sourceTree = SOURCE_ROOT; }; 03F84D1327DD414C008FE43F /* SentryAsyncSafeLogging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryAsyncSafeLogging.h; path = Sources/Sentry/include/SentryAsyncSafeLogging.h; sourceTree = SOURCE_ROOT; }; diff --git a/Sources/Sentry/Public/SentryOptions.h b/Sources/Sentry/Public/SentryOptions.h index 2b005e28f62..15708f3ace2 100644 --- a/Sources/Sentry/Public/SentryOptions.h +++ b/Sources/Sentry/Public/SentryOptions.h @@ -388,7 +388,7 @@ NS_SWIFT_NAME(Options) @property (nonatomic, assign) BOOL enableProfiling DEPRECATED_MSG_ATTRIBUTE( "Use profilesSampleRate or profilesSampler instead. This property will be removed in a future " "version of the SDK"); -#endif +#endif // SENTRY_TARGET_PROFILING_SUPPORTED /** * Whether to send client reports, which contain statistics about discarded events. diff --git a/Sources/Sentry/SentryHub.m b/Sources/Sentry/SentryHub.m index 5135a86b463..fbc13f91042 100644 --- a/Sources/Sentry/SentryHub.m +++ b/Sources/Sentry/SentryHub.m @@ -12,7 +12,7 @@ #import "SentryLog.h" #import "SentryNSTimerFactory.h" #import "SentryPerformanceTracker.h" -#import "SentryProfilesSampler.h" +#import "SentryProfilingConditionals.h" #import "SentrySDK+Private.h" #import "SentrySamplingContext.h" #import "SentryScope+Private.h" @@ -28,6 +28,10 @@ # import "SentryUIViewControllerPerformanceTracker.h" #endif // SENTRY_HAS_UIKIT +#if SENTRY_TARGET_PROFILING_SUPPORTED +# import "SentryProfilesSampler.h" +#endif // SENTRY_TARGET_PROFILING_SUPPORTED" + NS_ASSUME_NONNULL_BEGIN @interface @@ -38,7 +42,9 @@ @property (nullable, nonatomic, strong) SentryScope *scope; @property (nonatomic, strong) SentryCrashWrapper *crashWrapper; @property (nonatomic, strong) SentryTracesSampler *tracesSampler; +#if SENTRY_TARGET_PROFILING_SUPPORTED @property (nonatomic, strong) SentryProfilesSampler *profilesSampler; +#endif // SENTRY_TARGET_PROFILING_SUPPORTED @property (nonatomic, strong) NSMutableArray> *installedIntegrations; @property (nonatomic, strong) NSMutableSet *installedIntegrationNames; @property (nonatomic) NSUInteger errorsBeforeSession; @@ -67,7 +73,7 @@ - (instancetype)initWithClient:(nullable SentryClient *)client if (client.options.isProfilingEnabled) { _profilesSampler = [[SentryProfilesSampler alloc] initWithOptions:client.options]; } -#endif +#endif // SENTRY_TARGET_PROFILING_SUPPORTED } return self; } @@ -382,10 +388,12 @@ - (SentryTracer *)startTransactionWithContext:(SentryTransactionContext *)transa withSampled:samplerDecision.decision]; transactionContext.sampleRate = samplerDecision.sampleRate; +#if SENTRY_TARGET_PROFILING_SUPPORTED SentryProfilesSamplerDecision *profilesSamplerDecision = [_profilesSampler sample:samplingContext tracesSamplerDecision:samplerDecision]; configuration.profilesSamplerDecision = profilesSamplerDecision; +#endif // SENTRY_TARGET_PROFILING_SUPPORTED" SentryTracer *tracer = [[SentryTracer alloc] initWithTransactionContext:transactionContext hub:self @@ -660,7 +668,7 @@ - (void)reportFullyDisplayed } else { SENTRY_LOG_DEBUG(@"The options `enableTimeToFullDisplay` is disabled."); } -#endif +#endif // SENTRY_HAS_UIKIT } - (void)flush:(NSTimeInterval)timeout diff --git a/Sources/Sentry/SentryOptions.m b/Sources/Sentry/SentryOptions.m index c67efcd3582..d2b5a4133d0 100644 --- a/Sources/Sentry/SentryOptions.m +++ b/Sources/Sentry/SentryOptions.m @@ -11,7 +11,6 @@ #import "SentryLevelMapper.h" #import "SentryLog.h" #import "SentryMeta.h" -#import "SentryMetricKitIntegration.h" #import "SentryNetworkTrackingIntegration.h" #import "SentrySDK.h" #import "SentryScope.h" diff --git a/Sources/Sentry/SentryProfilesSampler.m b/Sources/Sentry/SentryProfilesSampler.m index d43cbef6cc5..8a3a1de63a7 100644 --- a/Sources/Sentry/SentryProfilesSampler.m +++ b/Sources/Sentry/SentryProfilesSampler.m @@ -1,7 +1,10 @@ #import "SentryProfilesSampler.h" -#import "SentryDependencyContainer.h" -#import "SentryOptions+Private.h" -#import "SentryTracesSampler.h" + +#if SENTRY_TARGET_PROFILING_SUPPORTED + +# import "SentryDependencyContainer.h" +# import "SentryOptions+Private.h" +# import "SentryTracesSampler.h" NS_ASSUME_NONNULL_BEGIN @@ -43,7 +46,6 @@ - (SentryProfilesSamplerDecision *)sample:(SentrySamplingContext *)context // Profiles are always undersampled with respect to traces. If the trace is not sampled, // the profile will not be either. If the trace is sampled, we can proceed to checking // whether the associated profile should be sampled. -#if SENTRY_TARGET_PROFILING_SUPPORTED if (tracesSamplerDecision.decision == kSentrySampleDecisionYes) { if (_options.profilesSampler != nil) { NSNumber *callbackDecision = _options.profilesSampler(context); @@ -70,7 +72,6 @@ - (SentryProfilesSamplerDecision *)sample:(SentrySamplingContext *)context } # pragma clang diagnostic pop } -#endif return [[SentryProfilesSamplerDecision alloc] initWithDecision:kSentrySampleDecisionNo forSampleRate:nil]; @@ -88,3 +89,5 @@ - (SentryProfilesSamplerDecision *)calcSample:(double)rate @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_TARGET_PROFILING_SUPPORTED diff --git a/Sources/Sentry/SentryTracer.m b/Sources/Sentry/SentryTracer.m index 5628b23ef0c..4898cf75b97 100644 --- a/Sources/Sentry/SentryTracer.m +++ b/Sources/Sentry/SentryTracer.m @@ -9,7 +9,6 @@ #import "SentryLog.h" #import "SentryNSTimerFactory.h" #import "SentryNoOpSpan.h" -#import "SentryProfilesSampler.h" #import "SentryProfilingConditionals.h" #import "SentrySDK+Private.h" #import "SentryScope.h" @@ -32,6 +31,7 @@ #if SENTRY_TARGET_PROFILING_SUPPORTED # import "SentryProfiledTracerConcurrency.h" # import "SentryProfiler.h" +# import "SentryProfilesSampler.h" #endif // SENTRY_TARGET_PROFILING_SUPPORTED #if SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentryProfilesSampler.h b/Sources/Sentry/include/SentryProfilesSampler.h index 81a89c7edbe..d07ac8320de 100644 --- a/Sources/Sentry/include/SentryProfilesSampler.h +++ b/Sources/Sentry/include/SentryProfilesSampler.h @@ -1,6 +1,10 @@ -#import "SentryRandom.h" -#import "SentrySampleDecision.h" -#import +#import "SentryProfilingConditionals.h" + +#if SENTRY_TARGET_PROFILING_SUPPORTED + +# import "SentryRandom.h" +# import "SentrySampleDecision.h" +# import NS_ASSUME_NONNULL_BEGIN @@ -47,3 +51,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + +#endif // SENTRY_TARGET_PROFILING_SUPPORTED diff --git a/Sources/Sentry/include/SentryTracerConfiguration.h b/Sources/Sentry/include/SentryTracerConfiguration.h index 03084b4a8f7..cb38c47745f 100644 --- a/Sources/Sentry/include/SentryTracerConfiguration.h +++ b/Sources/Sentry/include/SentryTracerConfiguration.h @@ -1,3 +1,9 @@ +#if __has_include() +# import +#else +# import "PrivatesHeader.h" +#endif + #import NS_ASSUME_NONNULL_BEGIN @@ -25,10 +31,12 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, strong, nullable) SentryDispatchQueueWrapper *dispatchQueueWrapper; +#if SENTRY_TARGET_PROFILING_SUPPORTED /** * Whether to sample a profile corresponding to this transaction */ @property (nonatomic, strong, nullable) SentryProfilesSamplerDecision *profilesSamplerDecision; +#endif // SENTRY_TARGET_PROFILING_SUPPORTED" /** * The idle time to wait until to finish the transaction diff --git a/Tests/SentryTests/SentrySDKTests.swift b/Tests/SentryTests/SentrySDKTests.swift index 7eb1bb1b9c0..4687cd9bc59 100644 --- a/Tests/SentryTests/SentrySDKTests.swift +++ b/Tests/SentryTests/SentrySDKTests.swift @@ -669,7 +669,7 @@ class SentrySDKTests: XCTestCase { queue1.activate() queue2.activate() group.waitWithTimeout(timeout: 100) - + let timestamp = SentryDependencyContainer.sharedInstance().dateProvider.date().addingTimeInterval(TimeInterval(amount)) XCTAssertEqual(timestamp, SentrySDK.getAppStartMeasurement()?.appStartTimestamp) } diff --git a/Tests/SentryTests/SentryTests-Bridging-Header.h b/Tests/SentryTests/SentryTests-Bridging-Header.h index e8ed68ae3e7..d0c129450d5 100644 --- a/Tests/SentryTests/SentryTests-Bridging-Header.h +++ b/Tests/SentryTests/SentryTests-Bridging-Header.h @@ -49,7 +49,6 @@ #import "SentryConcurrentRateLimitsDictionary.h" #import "SentryCoreDataSwizzling.h" #import "SentryCoreDataTracker+Test.h" -#import "SentryCoreDataTracker.h" #import "SentryCoreDataTrackingIntegration.h" #import "SentryCrashBinaryImageProvider.h" #import "SentryCrashC.h" diff --git a/Tests/SentryTests/Transaction/SentryTracerObjCTests.m b/Tests/SentryTests/Transaction/SentryTracerObjCTests.m index 8264e1c5963..16fe6673002 100644 --- a/Tests/SentryTests/Transaction/SentryTracerObjCTests.m +++ b/Tests/SentryTests/Transaction/SentryTracerObjCTests.m @@ -1,8 +1,6 @@ #import "SentryClient.h" #import "SentryHub.h" #import "SentryOptions.h" -#import "SentryProfiler.h" -#import "SentryProfilesSampler.h" #import "SentryProfilingConditionals.h" #import "SentrySpan.h" #import "SentryTests-Swift.h" @@ -10,6 +8,11 @@ #import "SentryTransactionContext.h" #import +#if SENTRY_TARGET_PROFILING_SUPPORTED +# import "SentryProfiler.h" +# import "SentryProfilesSampler.h" +#endif // SENTRY_TARGET_PROFILING_SUPPORTED + @interface SentryTracerObjCTests : XCTestCase @end