Switch to targeted Swift concurrency warnings + fix them

This commit is contained in:
Thomas Ricouard 2023-02-18 22:51:44 +01:00
parent a8459638e9
commit 4000dc3650
15 changed files with 33 additions and 31 deletions

View file

@ -1184,6 +1184,7 @@
SUPPORTS_MACCATALYST = NO; SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = targeted;
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
}; };
@ -1236,6 +1237,7 @@
SUPPORTS_MACCATALYST = NO; SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = targeted;
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
}; };

View file

@ -1,6 +1,6 @@
import Foundation import Foundation
public final class Account: Codable, Identifiable, Equatable, Hashable { public final class Account: Codable, Identifiable, Equatable, Hashable, Sendable {
public static func == (lhs: Account, rhs: Account) -> Bool { public static func == (lhs: Account, rhs: Account) -> Bool {
lhs.id == rhs.id lhs.id == rhs.id
} }
@ -9,7 +9,7 @@ public final class Account: Codable, Identifiable, Equatable, Hashable {
hasher.combine(id) hasher.combine(id)
} }
public struct Field: Codable, Equatable, Identifiable { public struct Field: Codable, Equatable, Identifiable, Sendable {
public var id: String { public var id: String {
value.asRawText + name value.asRawText + name
} }
@ -19,7 +19,7 @@ public final class Account: Codable, Identifiable, Equatable, Hashable {
public let verifiedAt: String? public let verifiedAt: String?
} }
public struct Source: Codable, Equatable { public struct Source: Codable, Equatable, Sendable {
public let privacy: Visibility public let privacy: Visibility
public let sensitive: Bool public let sensitive: Bool
public let language: String? public let language: String?

View file

@ -6,7 +6,7 @@ private enum CodingKeys: CodingKey {
case htmlValue, asMarkdown, asRawText, statusesURLs case htmlValue, asMarkdown, asRawText, statusesURLs
} }
public struct HTMLString: Codable, Equatable, Hashable { public struct HTMLString: Codable, Equatable, Hashable, @unchecked Sendable {
public var htmlValue: String = "" public var htmlValue: String = ""
public var asMarkdown: String = "" public var asMarkdown: String = ""
public var asRawText: String = "" public var asRawText: String = ""

View file

@ -4,7 +4,7 @@ private enum CodingKeys: CodingKey {
case asDate case asDate
} }
public struct ServerDate: Codable, Hashable, Equatable { public struct ServerDate: Codable, Hashable, Equatable, Sendable {
public let asDate: Date public let asDate: Date
public var relativeFormatted: String { public var relativeFormatted: String {

View file

@ -1,6 +1,6 @@
import Foundation import Foundation
public struct Emoji: Codable, Hashable, Identifiable, Equatable { public struct Emoji: Codable, Hashable, Identifiable, Equatable, Sendable {
public func hash(into hasher: inout Hasher) { public func hash(into hasher: inout Hasher) {
hasher.combine(shortcode) hasher.combine(shortcode)
} }

View file

@ -1,19 +1,19 @@
import Foundation import Foundation
public struct Instance: Codable { public struct Instance: Codable, Sendable {
public struct Stats: Codable { public struct Stats: Codable, Sendable {
public let userCount: Int public let userCount: Int
public let statusCount: Int public let statusCount: Int
public let domainCount: Int public let domainCount: Int
} }
public struct Configuration: Codable { public struct Configuration: Codable, Sendable {
public struct Statuses: Codable { public struct Statuses: Codable, Sendable {
public let maxCharacters: Int public let maxCharacters: Int
public let maxMediaAttachments: Int public let maxMediaAttachments: Int
} }
public struct Polls: Codable { public struct Polls: Codable, Sendable {
public let maxOptions: Int public let maxOptions: Int
public let maxCharactersPerOption: Int public let maxCharactersPerOption: Int
public let minExpiration: Int public let minExpiration: Int
@ -24,12 +24,12 @@ public struct Instance: Codable {
public let polls: Polls public let polls: Polls
} }
public struct Rule: Codable, Identifiable { public struct Rule: Codable, Identifiable, Sendable {
public let id: String public let id: String
public let text: String public let text: String
} }
public struct URLs: Codable { public struct URLs: Codable, Sendable {
public let streamingApi: URL? public let streamingApi: URL?
} }

View file

@ -1,7 +1,7 @@
import Foundation import Foundation
public struct InstanceSocial: Decodable, Identifiable { public struct InstanceSocial: Decodable, Identifiable, Sendable {
public struct Info: Decodable { public struct Info: Decodable, Sendable {
public let shortDescription: String? public let shortDescription: String?
} }

View file

@ -1,6 +1,6 @@
import Foundation import Foundation
public struct OauthToken: Codable, Hashable { public struct OauthToken: Codable, Hashable, Sendable {
public let accessToken: String public let accessToken: String
public let tokenType: String public let tokenType: String
public let scope: String public let scope: String

View file

@ -1,17 +1,17 @@
import Foundation import Foundation
public struct ServerFilter: Codable, Identifiable, Hashable { public struct ServerFilter: Codable, Identifiable, Hashable, Sendable {
public struct Keyword: Codable, Identifiable, Hashable { public struct Keyword: Codable, Identifiable, Hashable, Sendable {
public let id: String public let id: String
public let keyword: String public let keyword: String
public let wholeWord: Bool public let wholeWord: Bool
} }
public enum Context: String, Codable, CaseIterable { public enum Context: String, Codable, CaseIterable, Sendable {
case home, notifications, `public`, thread, account case home, notifications, `public`, thread, account
} }
public enum Action: String, Codable, CaseIterable { public enum Action: String, Codable, CaseIterable, Sendable {
case warn, hide case warn, hide
} }

View file

@ -18,7 +18,7 @@ public extension Application {
} }
} }
public enum Visibility: String, Codable, CaseIterable, Hashable, Equatable { public enum Visibility: String, Codable, CaseIterable, Hashable, Equatable, Sendable {
case pub = "public" case pub = "public"
case unlisted case unlisted
case priv = "private" case priv = "private"

View file

@ -2,14 +2,14 @@ import Foundation
import Models import Models
import SwiftUI import SwiftUI
public class Client: ObservableObject, Equatable, Identifiable, Hashable { public final class Client: ObservableObject, Equatable, Identifiable, Hashable, @unchecked Sendable {
public static func == (lhs: Client, rhs: Client) -> Bool { public static func == (lhs: Client, rhs: Client) -> Bool {
lhs.isAuth == rhs.isAuth && lhs.isAuth == rhs.isAuth &&
lhs.server == rhs.server && lhs.server == rhs.server &&
lhs.oauthToken?.accessToken == rhs.oauthToken?.accessToken lhs.oauthToken?.accessToken == rhs.oauthToken?.accessToken
} }
public enum Version: String { public enum Version: String, Sendable {
case v1, v2 case v1, v2
} }
@ -26,7 +26,7 @@ public class Client: ObservableObject, Equatable, Identifiable, Hashable {
hasher.combine(id) hasher.combine(id)
} }
public var server: String public let server: String
public let version: Version public let version: Version
public private(set) var connections: Set<String> public private(set) var connections: Set<String>
private let urlSession: URLSession private let urlSession: URLSession

View file

@ -154,7 +154,7 @@ public enum Accounts: Endpoint {
} }
} }
public struct MuteData: Encodable { public struct MuteData: Encodable, Sendable {
public let duration: Int public let duration: Int
public init(duration: Int) { public init(duration: Int) {
@ -162,7 +162,7 @@ public struct MuteData: Encodable {
} }
} }
public struct RelationshipNoteData: Encodable { public struct RelationshipNoteData: Encodable, Sendable {
public let comment: String public let comment: String
public init(note comment: String) { public init(note comment: String) {

View file

@ -1,6 +1,6 @@
import Foundation import Foundation
public protocol Endpoint { public protocol Endpoint: Sendable {
func path() -> String func path() -> String
func queryItems() -> [URLQueryItem]? func queryItems() -> [URLQueryItem]?
var jsonValue: Encodable? { get } var jsonValue: Encodable? { get }

View file

@ -48,7 +48,7 @@ public enum ServerFilters: Endpoint {
} }
} }
public struct ServerFilterData: Encodable { public struct ServerFilterData: Encodable, Sendable {
public let title: String public let title: String
public let context: [ServerFilter.Context] public let context: [ServerFilter.Context]
public let filterAction: ServerFilter.Action public let filterAction: ServerFilter.Action

View file

@ -91,7 +91,7 @@ public enum Statuses: Endpoint {
} }
} }
public struct StatusData: Encodable { public struct StatusData: Encodable, Sendable {
public let status: String public let status: String
public let visibility: Visibility public let visibility: Visibility
public let inReplyToId: String? public let inReplyToId: String?
@ -101,7 +101,7 @@ public struct StatusData: Encodable {
public let language: String? public let language: String?
public let mediaAttributes: [MediaAttribute]? public let mediaAttributes: [MediaAttribute]?
public struct PollData: Encodable { public struct PollData: Encodable, Sendable {
public let options: [String] public let options: [String]
public let multiple: Bool public let multiple: Bool
public let expires_in: Int public let expires_in: Int
@ -113,7 +113,7 @@ public struct StatusData: Encodable {
} }
} }
public struct MediaAttribute: Encodable { public struct MediaAttribute: Encodable, Sendable {
public let id: String public let id: String
public let description: String? public let description: String?
public let thumbnail: String? public let thumbnail: String?