Swift 6 migration for NSE (#5608)

* swift 6 support for NSE and concurrency safe implementations for it

* enforcing required Sendable conformance for swift 6 migration in NSE

* use Mutex to access the string builder cache

* use an async stream to update timeline items diffs

* fix for Sendable appHooks
This commit is contained in:
Mauro
2026-05-21 20:21:57 +02:00
committed by GitHub
parent 91ccff36fc
commit 2462ddea85
20 changed files with 226 additions and 150 deletions
@@ -14,7 +14,7 @@ import Foundation
import SwiftUI
/// Common settings between app and NSE
protocol CommonSettingsProtocol: AnyObject {
protocol CommonSettingsProtocol: AnyObject, Sendable {
var lastNotificationBootTime: TimeInterval? { get set }
var selectedNotificationTone: NotificationTone? { get set }
@@ -34,7 +34,9 @@ enum AppBuildType {
}
/// Store Element specific app settings.
final class AppSettings {
///
/// State is persisted in `UserDefaults`, which is thread-safe per Apple's documentation, hence `@unchecked`.
final class AppSettings: @unchecked Sendable {
private enum UserDefaultsKeys: String {
case lastVersionLaunched
case seenInvites
@@ -92,10 +94,10 @@ final class AppSettings {
case developerOptionsEnabled
}
private static var suiteName: String = InfoPlistReader.main.appGroupIdentifier
private nonisolated(unsafe) static var suiteName: String = InfoPlistReader.main.appGroupIdentifier
/// UserDefaults to be used on reads and writes.
private static var store: UserDefaults! = UserDefaults(suiteName: suiteName)
/// UserDefaults to be used on reads and writes. `UserDefaults` is thread-safe per Apple's documentation.
private nonisolated(unsafe) static var store: UserDefaults! = UserDefaults(suiteName: suiteName)
static var appBuildType: AppBuildType {
#if DEBUG