on master help sign in
fix: CI — @MainActor isolation errors in AppDelegate

ViewModel is @MainActor, but AppDelegate accessed it from a nonisolated context (NSApplicationDelegate methods, Timer closure, @objc action handlers). This caused 4 compile errors on Xcode 16.4: - init(checker:defaults:) called in nonisolated context - refreshIntervalMinutes referenced from nonisolated context - refresh() called from nonisolated context (systemDidWake, refreshFromMenu) Fix: mark AppDelegate @MainActor (all its methods are called on the main thread anyway). Wrap Timer closure body in Task { @MainActor in } since Timer closures are @Sendable/nonisolated.

commitf3f0f41e64583b452dbd0373d9f13b640d2eac91 authoriko <mail@iko.soy> dateSat 11 Jul 2026, 17:26 (3 months ago) parent461e147
1 file changed+6−1
HyperCreditsMenubar/HyperCreditsApp.swift+6−1
HyperCreditsMenubar/HyperCreditsApp.swift+6−1
@@ -4,6 +4,11 @@ import UserNotifications
44
55/// Main app delegate that manages the menu bar item, the refresh timer,
66/// the SwiftUI popover hosting `MenuView`, and sleep/wake handling.
7+///
8+/// Marked `@MainActor` because `ViewModel` is `@MainActor`-isolated and the
9+/// delegate accesses it directly. All `NSApplicationDelegate` methods are
10+/// called on the main thread regardless, so this is semantically correct.
11+@MainActor
712final class AppDelegate: NSObject, NSApplicationDelegate {
813 private var statusItem: NSStatusItem!
914 private var popover: NSPopover!
@@ -96,7 +101,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
96101 let interval = TimeInterval(minutes * 60)
97102
98103 let timer = Timer(timeInterval: interval, repeats: true) { [weak self] _ in
99− self?.viewModel.refresh()
104+ Task { @MainActor in self?.viewModel.refresh() }
100105 }
101106 RunLoop.main.add(timer, forMode: .common)
102107 refreshTimer = timer