From 36fec7e6ca5e99c6049771601770a5488021e19a Mon Sep 17 00:00:00 2001 From: joker <824219521@qq.com> Date: Thu, 18 Jul 2024 18:02:41 +0800 Subject: [PATCH] Adjust to Swift 6 toolchain compile (#202) * Migrate to Swift 6 * add the @preconcurrency attribute before func shutdown --------- Co-authored-by: wangzhizhou --- Sources/APNS/APNSClient.swift | 2 +- Sources/APNS/APNSConfiguration.swift | 4 ++-- Sources/APNSCore/APNSError.swift | 4 ++-- Sources/APNSCore/Base64.swift | 4 ++-- .../APNSCore/LiveActivity/APNSLiveActivityDismissalDate.swift | 2 +- .../APNSCore/LiveActivity/APNSLiveActivityNotification.swift | 2 +- .../LiveActivity/APNSLiveActivityNotificationAPSStorage.swift | 2 +- .../LiveActivity/APNSLiveActivityNotificationEvent.swift | 2 +- .../LiveActivity/APNSStartLiveActivityNotification.swift | 2 +- .../APNSStartLiveActivityNotificationAPSStorage.swift | 4 ++-- .../APNSURLSession/APNSURLSessionClientConfiguration.swift | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Sources/APNS/APNSClient.swift b/Sources/APNS/APNSClient.swift index a1c38268..2e648ede 100644 --- a/Sources/APNS/APNSClient.swift +++ b/Sources/APNS/APNSClient.swift @@ -125,7 +125,7 @@ public final class APNSClient Void) { + @preconcurrency public func shutdown(queue: DispatchQueue = .global(), callback: @Sendable @escaping (Error?) -> Void) { self.httpClient.shutdown(callback) } diff --git a/Sources/APNS/APNSConfiguration.swift b/Sources/APNS/APNSConfiguration.swift index c2392a8b..ba62c6d5 100644 --- a/Sources/APNS/APNSConfiguration.swift +++ b/Sources/APNS/APNSConfiguration.swift @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// import APNSCore -import Crypto +@preconcurrency import Crypto import NIOSSL import NIOTLS import AsyncHTTPClient @@ -22,7 +22,7 @@ import AsyncHTTPClient public struct APNSClientConfiguration: Sendable { /// The authentication method used by the ``APNSClient``. public struct AuthenticationMethod: Sendable { - internal enum Method { + internal enum Method : Sendable{ case jwt(privateKey: P256.Signing.PrivateKey, teamIdentifier: String, keyIdentifier: String) case tls(privateKey: NIOSSLPrivateKeySource, certificateChain: [NIOSSLCertificateSource]) } diff --git a/Sources/APNSCore/APNSError.swift b/Sources/APNSCore/APNSError.swift index 41bd2c6c..4a7c0b64 100644 --- a/Sources/APNSCore/APNSError.swift +++ b/Sources/APNSCore/APNSError.swift @@ -21,8 +21,8 @@ public struct APNSError: Error { /// The error reason returned by APNs. /// /// For more information please look here: [Reference]( https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/handling_notification_responses_from_apns) - public struct ErrorReason: Hashable { - public enum Reason: RawRepresentable, Hashable { + public struct ErrorReason: Hashable, Sendable { + public enum Reason: RawRepresentable, Hashable, Sendable { public typealias RawValue = String case badCollapseIdentifier diff --git a/Sources/APNSCore/Base64.swift b/Sources/APNSCore/Base64.swift index 46bd3f24..c78fa67a 100644 --- a/Sources/APNSCore/Base64.swift +++ b/Sources/APNSCore/Base64.swift @@ -89,7 +89,7 @@ internal enum Base64 {} extension Base64 { @usableFromInline - internal struct EncodingOptions: OptionSet { + internal struct EncodingOptions: OptionSet, Sendable { @usableFromInline internal let rawValue: UInt @@ -557,7 +557,7 @@ extension Base64 { extension Base64 { @usableFromInline - internal struct DecodingOptions: OptionSet { + internal struct DecodingOptions: OptionSet, Sendable { @usableFromInline internal let rawValue: UInt diff --git a/Sources/APNSCore/LiveActivity/APNSLiveActivityDismissalDate.swift b/Sources/APNSCore/LiveActivity/APNSLiveActivityDismissalDate.swift index cb1112d8..9bd7d4e8 100644 --- a/Sources/APNSCore/LiveActivity/APNSLiveActivityDismissalDate.swift +++ b/Sources/APNSCore/LiveActivity/APNSLiveActivityDismissalDate.swift @@ -14,7 +14,7 @@ import struct Foundation.Date -public struct APNSLiveActivityDismissalDate: Hashable { +public struct APNSLiveActivityDismissalDate: Hashable, Sendable { /// The date at which the live activity will be dismissed /// This value is a UNIX epoch expressed in seconds (UTC) @usableFromInline diff --git a/Sources/APNSCore/LiveActivity/APNSLiveActivityNotification.swift b/Sources/APNSCore/LiveActivity/APNSLiveActivityNotification.swift index 135a193b..358d16bb 100644 --- a/Sources/APNSCore/LiveActivity/APNSLiveActivityNotification.swift +++ b/Sources/APNSCore/LiveActivity/APNSLiveActivityNotification.swift @@ -17,7 +17,7 @@ import struct Foundation.UUID /// A live activity notification. /// /// It is **important** that you do not encode anything with the key `aps`. -public struct APNSLiveActivityNotification: APNSMessage { +public struct APNSLiveActivityNotification: APNSMessage { enum CodingKeys: CodingKey { case aps } diff --git a/Sources/APNSCore/LiveActivity/APNSLiveActivityNotificationAPSStorage.swift b/Sources/APNSCore/LiveActivity/APNSLiveActivityNotificationAPSStorage.swift index 756c747c..7bde9767 100644 --- a/Sources/APNSCore/LiveActivity/APNSLiveActivityNotificationAPSStorage.swift +++ b/Sources/APNSCore/LiveActivity/APNSLiveActivityNotificationAPSStorage.swift @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -struct APNSLiveActivityNotificationAPSStorage: Encodable { +struct APNSLiveActivityNotificationAPSStorage: Encodable { enum CodingKeys: String, CodingKey { case timestamp = "timestamp" case event = "event" diff --git a/Sources/APNSCore/LiveActivity/APNSLiveActivityNotificationEvent.swift b/Sources/APNSCore/LiveActivity/APNSLiveActivityNotificationEvent.swift index 9f925f80..b0f6ca22 100644 --- a/Sources/APNSCore/LiveActivity/APNSLiveActivityNotificationEvent.swift +++ b/Sources/APNSCore/LiveActivity/APNSLiveActivityNotificationEvent.swift @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -public struct APNSLiveActivityNotificationEvent: Hashable { +public struct APNSLiveActivityNotificationEvent: Hashable, Sendable { /// The underlying raw value that is send to APNs. @usableFromInline internal let rawValue: String diff --git a/Sources/APNSCore/LiveActivity/APNSStartLiveActivityNotification.swift b/Sources/APNSCore/LiveActivity/APNSStartLiveActivityNotification.swift index 4a722465..0c5c9d2e 100644 --- a/Sources/APNSCore/LiveActivity/APNSStartLiveActivityNotification.swift +++ b/Sources/APNSCore/LiveActivity/APNSStartLiveActivityNotification.swift @@ -17,7 +17,7 @@ import struct Foundation.UUID /// A notification that starts a live activity /// /// It is **important** that you do not encode anything with the key `aps`. -public struct APNSStartLiveActivityNotification: +public struct APNSStartLiveActivityNotification: APNSMessage { enum CodingKeys: CodingKey { diff --git a/Sources/APNSCore/LiveActivity/APNSStartLiveActivityNotificationAPSStorage.swift b/Sources/APNSCore/LiveActivity/APNSStartLiveActivityNotificationAPSStorage.swift index 2fd1947e..58ddb359 100644 --- a/Sources/APNSCore/LiveActivity/APNSStartLiveActivityNotificationAPSStorage.swift +++ b/Sources/APNSCore/LiveActivity/APNSStartLiveActivityNotificationAPSStorage.swift @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -struct APNSStartLiveActivityNotificationAPSStorage: - Encodable +struct APNSStartLiveActivityNotificationAPSStorage: + Encodable & Sendable { enum CodingKeys: String, CodingKey { case timestamp = "timestamp" diff --git a/Sources/APNSURLSession/APNSURLSessionClientConfiguration.swift b/Sources/APNSURLSession/APNSURLSessionClientConfiguration.swift index e89dae9e..501a6cc7 100644 --- a/Sources/APNSURLSession/APNSURLSessionClientConfiguration.swift +++ b/Sources/APNSURLSession/APNSURLSessionClientConfiguration.swift @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// import APNSCore -import Crypto +@preconcurrency import Crypto /// The configuration of an ``APNSURLSessionClient``. public struct APNSURLSessionClientConfiguration {