From 9a0b87eca1f78aa5e7fe05022408108f224705a7 Mon Sep 17 00:00:00 2001 From: Noah Martin Date: Fri, 5 Dec 2025 11:39:02 +0100 Subject: [PATCH] fix: Remove extra @objc from SessionTracker --- .../Sources/TestNSNotificationCenterWrapper.swift | 8 ++++---- .../Swift/Integrations/Session/SessionTracker.swift | 12 +++++------- Sources/Swift/SentryDependencyContainer.swift | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/SentryTestUtils/Sources/TestNSNotificationCenterWrapper.swift b/SentryTestUtils/Sources/TestNSNotificationCenterWrapper.swift index b8e4dc42746..185be9cdd5b 100644 --- a/SentryTestUtils/Sources/TestNSNotificationCenterWrapper.swift +++ b/SentryTestUtils/Sources/TestNSNotificationCenterWrapper.swift @@ -11,7 +11,7 @@ public typealias CrossPlatformApplication = NSApplication @objcMembers public class TestNSNotificationCenterWrapper: NSObject { private enum Observer { - case observerWithObject(WeakReference, Selector, NSNotification.Name?, Any?) + case observerWithObject(WeakReference, Selector, NSNotification.Name?, Any?) case observerForKeyPath(WeakReference, String, NSKeyValueObservingOptions, UnsafeMutableRawPointer?) case observerWithBlock(WeakReference, NSNotification.Name?, (Notification) -> Void) } @@ -22,7 +22,7 @@ public typealias CrossPlatformApplication = NSApplication private var observers: [Observer] = [] public var addObserverWithObjectInvocations = Invocations<( - observer: WeakReference, + observer: WeakReference, selector: Selector, name: NSNotification.Name?, object: Any? @@ -34,8 +34,8 @@ public typealias CrossPlatformApplication = NSApplication object anObject: Any? = nil ) { if ignoreAddObserver == false { - addObserverWithObjectInvocations.record((WeakReference(value: observer as! NSObject), aSelector, aName, anObject)) - observers.append(.observerWithObject(WeakReference(value: observer as! NSObject), aSelector, aName, anObject)) + addObserverWithObjectInvocations.record((WeakReference(value: observer as AnyObject), aSelector, aName, anObject)) + observers.append(.observerWithObject(WeakReference(value: observer as AnyObject), aSelector, aName, anObject)) } } diff --git a/Sources/Swift/Integrations/Session/SessionTracker.swift b/Sources/Swift/Integrations/Session/SessionTracker.swift index 87ebce7145a..3d29709b5d0 100644 --- a/Sources/Swift/Integrations/Session/SessionTracker.swift +++ b/Sources/Swift/Integrations/Session/SessionTracker.swift @@ -10,7 +10,7 @@ typealias Application = NSApplication /// Tracks sessions for release health. For more info see: /// https://docs.sentry.io/workflow/releases/health/#session -@_spi(Private) @objc(SentrySessionTracker) public final class SessionTracker: NSObject { +final class SessionTracker { // MARK: Private @@ -39,9 +39,9 @@ typealias Application = NSApplication self.notificationCenter.removeObserver(self, name: nil, object: nil) } - // MARK: Public + // MARK: Internal - @objc public func start() { + func start() { // We don't want to use WillEnterForeground because tvOS doesn't call it when it launches an app // the first time. It only calls it when the app was open and the user navigates back to it. // DidEnterBackground is called when the app launches a background task so we would need to @@ -73,7 +73,7 @@ typealias Application = NSApplication #endif } - @objc public func stop() { + func stop() { SentrySDKInternal.currentHub().endSession() removeObservers() @@ -83,7 +83,7 @@ typealias Application = NSApplication wasStartSessionCalled = false } - @objc public func removeObservers() { + func removeObservers() { #if ((os(iOS) || os(tvOS) || (swift(>=5.9) && os(visionOS))) && !SENTRY_NO_UIKIT) || ((os(macOS) || targetEnvironment(macCatalyst)) && !SENTRY_NO_UIKIT) // Remove the observers with the most specific detail possible, see // https://developer.apple.com/documentation/foundation/nsnotificationcenter/1413994-removeobserver @@ -94,8 +94,6 @@ typealias Application = NSApplication #endif } - // MARK: Internal - let options: Options let dateProvider: SentryCurrentDateProvider let notificationCenter: SentryNSNotificationCenterWrapper diff --git a/Sources/Swift/SentryDependencyContainer.swift b/Sources/Swift/SentryDependencyContainer.swift index 478c9afa9c8..378f6870e65 100644 --- a/Sources/Swift/SentryDependencyContainer.swift +++ b/Sources/Swift/SentryDependencyContainer.swift @@ -98,7 +98,7 @@ extension SentryFileManager: SentryFileManagerProtocol { } return defaultApplicationProvider() } - @objc(getSessionTrackerWithOptions:) public func getSessionTracker(with options: Options) -> SessionTracker { + func getSessionTracker(with options: Options) -> SessionTracker { return SessionTracker(options: options, applicationProvider: defaultApplicationProvider, dateProvider: dateProvider, notificationCenter: notificationCenterWrapper) }