Skip to content

Commit 9a0b87e

Browse files
committed
fix: Remove extra @objc from SessionTracker
1 parent 4ef85d2 commit 9a0b87e

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

SentryTestUtils/Sources/TestNSNotificationCenterWrapper.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public typealias CrossPlatformApplication = NSApplication
1111

1212
@objcMembers public class TestNSNotificationCenterWrapper: NSObject {
1313
private enum Observer {
14-
case observerWithObject(WeakReference<NSObject>, Selector, NSNotification.Name?, Any?)
14+
case observerWithObject(WeakReference<AnyObject>, Selector, NSNotification.Name?, Any?)
1515
case observerForKeyPath(WeakReference<NSObject>, String, NSKeyValueObservingOptions, UnsafeMutableRawPointer?)
1616
case observerWithBlock(WeakReference<NSObject>, NSNotification.Name?, (Notification) -> Void)
1717
}
@@ -22,7 +22,7 @@ public typealias CrossPlatformApplication = NSApplication
2222
private var observers: [Observer] = []
2323

2424
public var addObserverWithObjectInvocations = Invocations<(
25-
observer: WeakReference<NSObject>,
25+
observer: WeakReference<AnyObject>,
2626
selector: Selector,
2727
name: NSNotification.Name?,
2828
object: Any?
@@ -34,8 +34,8 @@ public typealias CrossPlatformApplication = NSApplication
3434
object anObject: Any? = nil
3535
) {
3636
if ignoreAddObserver == false {
37-
addObserverWithObjectInvocations.record((WeakReference(value: observer as! NSObject), aSelector, aName, anObject))
38-
observers.append(.observerWithObject(WeakReference(value: observer as! NSObject), aSelector, aName, anObject))
37+
addObserverWithObjectInvocations.record((WeakReference(value: observer as AnyObject), aSelector, aName, anObject))
38+
observers.append(.observerWithObject(WeakReference(value: observer as AnyObject), aSelector, aName, anObject))
3939
}
4040
}
4141

Sources/Swift/Integrations/Session/SessionTracker.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ typealias Application = NSApplication
1010

1111
/// Tracks sessions for release health. For more info see:
1212
/// https://docs.sentry.io/workflow/releases/health/#session
13-
@_spi(Private) @objc(SentrySessionTracker) public final class SessionTracker: NSObject {
13+
final class SessionTracker {
1414

1515
// MARK: Private
1616

@@ -39,9 +39,9 @@ typealias Application = NSApplication
3939
self.notificationCenter.removeObserver(self, name: nil, object: nil)
4040
}
4141

42-
// MARK: Public
42+
// MARK: Internal
4343

44-
@objc public func start() {
44+
func start() {
4545
// We don't want to use WillEnterForeground because tvOS doesn't call it when it launches an app
4646
// the first time. It only calls it when the app was open and the user navigates back to it.
4747
// DidEnterBackground is called when the app launches a background task so we would need to
@@ -73,7 +73,7 @@ typealias Application = NSApplication
7373
#endif
7474
}
7575

76-
@objc public func stop() {
76+
func stop() {
7777
SentrySDKInternal.currentHub().endSession()
7878

7979
removeObservers()
@@ -83,7 +83,7 @@ typealias Application = NSApplication
8383
wasStartSessionCalled = false
8484
}
8585

86-
@objc public func removeObservers() {
86+
func removeObservers() {
8787
#if ((os(iOS) || os(tvOS) || (swift(>=5.9) && os(visionOS))) && !SENTRY_NO_UIKIT) || ((os(macOS) || targetEnvironment(macCatalyst)) && !SENTRY_NO_UIKIT)
8888
// Remove the observers with the most specific detail possible, see
8989
// https://developer.apple.com/documentation/foundation/nsnotificationcenter/1413994-removeobserver
@@ -94,8 +94,6 @@ typealias Application = NSApplication
9494
#endif
9595
}
9696

97-
// MARK: Internal
98-
9997
let options: Options
10098
let dateProvider: SentryCurrentDateProvider
10199
let notificationCenter: SentryNSNotificationCenterWrapper

Sources/Swift/SentryDependencyContainer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ extension SentryFileManager: SentryFileManagerProtocol { }
9898
return defaultApplicationProvider()
9999
}
100100

101-
@objc(getSessionTrackerWithOptions:) public func getSessionTracker(with options: Options) -> SessionTracker {
101+
func getSessionTracker(with options: Options) -> SessionTracker {
102102
return SessionTracker(options: options, applicationProvider: defaultApplicationProvider, dateProvider: dateProvider, notificationCenter: notificationCenterWrapper)
103103
}
104104

0 commit comments

Comments
 (0)