From 283fbf00fdffd64c924b6cb22c84e803b718f078 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Fri, 7 Aug 2026 17:33:46 -0500 Subject: Adopt Swift 6 language mode Flip SWIFT_VERSION to 6.0 (keeping SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor) and resolve every resulting diagnostic. Mechanical, no behaviour change: - Models: pure value types in Models/ and utility extensions (Date, DateFormatter, SRHTWebURL) marked nonisolated so the nonisolated networking layer can use them. - App Intents: stored 'static var' (title/description/openAppWhenRun/ typeDisplayRepresentation/defaultQuery/caseDisplayRepresentations) -> 'static let'; drop the invalid @retroactive on the in-module LookupType: AppEnum. - Sendable dicts: 'nil as String? as Any' -> 'nil as String? as any Sendable'. - UserDefaults: retroactive @unchecked Sendable (documented thread-safe). - WidgetKit completion handlers rebound nonisolated(unsafe) to cross into Task {}; TipStoreViewModel task handle is @ObservationIgnored nonisolated(unsafe) for its nonisolated deinit. - Tests run on @MainActor; a few constant fixtures marked nonisolated for use in @Sendable stub closures. Builds and the full suite are clean in Swift 6 mode. Roadmap updated. --- Hutch/Extensions/Date+Relative.swift | 2 +- Hutch/Extensions/DateFormatter+SRHT.swift | 2 +- Hutch/Extensions/Foundation+Sendable.swift | 7 +++++++ Hutch/Extensions/SRHTWebURL.swift | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 Hutch/Extensions/Foundation+Sendable.swift (limited to 'Hutch/Extensions') diff --git a/Hutch/Extensions/Date+Relative.swift b/Hutch/Extensions/Date+Relative.swift index f06ba59..b6c28ed 100644 --- a/Hutch/Extensions/Date+Relative.swift +++ b/Hutch/Extensions/Date+Relative.swift @@ -1,6 +1,6 @@ import Foundation -extension Date { +nonisolated extension Date { /// A short relative description like "2h ago", "3d ago", or "Jan 5, 2025". var relativeDescription: String { let formatter = RelativeDateTimeFormatter() diff --git a/Hutch/Extensions/DateFormatter+SRHT.swift b/Hutch/Extensions/DateFormatter+SRHT.swift index c017b11..a06b58a 100644 --- a/Hutch/Extensions/DateFormatter+SRHT.swift +++ b/Hutch/Extensions/DateFormatter+SRHT.swift @@ -1,6 +1,6 @@ import Foundation -extension DateFormatter { +nonisolated extension DateFormatter { /// Formatter for the sr.ht `Time` scalar: `%Y-%m-%dT%H:%M:%SZ` (UTC). static let srht: DateFormatter = { let formatter = DateFormatter() diff --git a/Hutch/Extensions/Foundation+Sendable.swift b/Hutch/Extensions/Foundation+Sendable.swift new file mode 100644 index 0000000..9a12aa6 --- /dev/null +++ b/Hutch/Extensions/Foundation+Sendable.swift @@ -0,0 +1,7 @@ +import Foundation + +// `UserDefaults` is documented as thread-safe but is not marked `Sendable` by +// Foundation. Hutch passes it into account sessions and the various per-account +// stores, all of which need to cross concurrency boundaries. The retroactive +// unchecked conformance reflects the documented thread-safety. +extension UserDefaults: @retroactive @unchecked Sendable {} diff --git a/Hutch/Extensions/SRHTWebURL.swift b/Hutch/Extensions/SRHTWebURL.swift index fc5a1d5..5715ce4 100644 --- a/Hutch/Extensions/SRHTWebURL.swift +++ b/Hutch/Extensions/SRHTWebURL.swift @@ -1,6 +1,6 @@ import Foundation -enum SRHTWebURL { +nonisolated enum SRHTWebURL { static let chat = URL(string: "https://chat.sr.ht")! static let status = URL(string: "https://status.sr.ht")! /// RSS/Atom feed for status incidents (HTML snapshot uses `status`). -- cgit v1.2.3