From ed1872a2218f5ccea0b0f034a767519e9144d1d3 Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Wed, 10 Jun 2026 17:51:20 +0100 Subject: [PATCH] Fix remaining Swift 6 concurrency issues --- .../ApplePayAuthorizationDelegate.swift | 4 +- .../ApplePay/ApplePayViewController.swift | 2 +- .../ShopPay/ShopPayViewController.swift | 2 +- .../Wallets/WalletController.swift | 2 +- .../ShopifyCheckoutKit/Configuration.swift | 2 +- .../ShopifyAcceleratedCheckoutsTests.swift | 1 + .../SwiftUITests.swift | 12 +- platforms/swift/api/ShopifyCheckoutKit.json | 17 +++ .../swift/api/ShopifyCheckoutProtocol.json | 125 ++++++++++++------ 9 files changed, 118 insertions(+), 49 deletions(-) diff --git a/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/ApplePay/ApplePayAuthorizationDelegate/ApplePayAuthorizationDelegate.swift b/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/ApplePay/ApplePayAuthorizationDelegate/ApplePayAuthorizationDelegate.swift index 42aea8fc..006fec19 100644 --- a/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/ApplePay/ApplePayAuthorizationDelegate/ApplePayAuthorizationDelegate.swift +++ b/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/ApplePay/ApplePayAuthorizationDelegate/ApplePayAuthorizationDelegate.swift @@ -16,11 +16,11 @@ protocol PaymentAuthorizationController { extension PKPaymentAuthorizationController: PaymentAuthorizationController {} @available(iOS 16.0, *) -typealias PKAuthorizationControllerFactory = @MainActor (PKPaymentRequest) -> any PaymentAuthorizationController +typealias PKAuthorizationControllerFactory = @MainActor @Sendable (PKPaymentRequest) -> any PaymentAuthorizationController @available(iOS 16.0, *) @MainActor -class ApplePayAuthorizationDelegate: NSObject, ObservableObject { +class ApplePayAuthorizationDelegate: NSObject, ObservableObject, @unchecked Sendable { let configuration: ApplePayConfigurationWrapper let abortError = ShopifyAcceleratedCheckouts.Error.invariant(expected: "cart") var controller: PayController diff --git a/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/ApplePay/ApplePayViewController.swift b/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/ApplePay/ApplePayViewController.swift index a231e878..f8111af6 100644 --- a/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/ApplePay/ApplePayViewController.swift +++ b/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/ApplePay/ApplePayViewController.swift @@ -14,7 +14,7 @@ protocol PayController: AnyObject { @available(iOS 16.0, *) @MainActor -class ApplePayViewController: WalletController, PayController { +class ApplePayViewController: WalletController, PayController, @unchecked Sendable { @Published var paymentController: PKPaymentAuthorizationController? var cart: StorefrontAPI.Types.Cart? diff --git a/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/ShopPay/ShopPayViewController.swift b/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/ShopPay/ShopPayViewController.swift index 8bc19170..b2467eea 100644 --- a/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/ShopPay/ShopPayViewController.swift +++ b/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/ShopPay/ShopPayViewController.swift @@ -3,7 +3,7 @@ import SwiftUI @available(iOS 16.0, *) @MainActor -class ShopPayViewController: WalletController { +class ShopPayViewController: WalletController, @unchecked Sendable { var eventHandlers: EventHandlers var client: (any CheckoutCommunicationProtocol)? diff --git a/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/WalletController.swift b/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/WalletController.swift index 128d7180..88108592 100644 --- a/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/WalletController.swift +++ b/platforms/swift/Sources/ShopifyAcceleratedCheckouts/Wallets/WalletController.swift @@ -3,7 +3,7 @@ import SwiftUI @available(iOS 16.0, *) @MainActor -class WalletController: ObservableObject { +class WalletController: ObservableObject, @unchecked Sendable { @Published var identifier: CheckoutIdentifier @Published var storefront: StorefrontAPIProtocol @Published var checkoutViewController: CheckoutViewController? diff --git a/platforms/swift/Sources/ShopifyCheckoutKit/Configuration.swift b/platforms/swift/Sources/ShopifyCheckoutKit/Configuration.swift index ab0da97b..cb11c0f2 100644 --- a/platforms/swift/Sources/ShopifyCheckoutKit/Configuration.swift +++ b/platforms/swift/Sources/ShopifyCheckoutKit/Configuration.swift @@ -1,6 +1,6 @@ import UIKit -public struct Platform: Equatable { +public struct Platform: Equatable, Sendable { public let identifier: String public let version: String? diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/ShopifyAcceleratedCheckoutsTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/ShopifyAcceleratedCheckoutsTests.swift index 946168b1..5e869bd4 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/ShopifyAcceleratedCheckoutsTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/ShopifyAcceleratedCheckoutsTests.swift @@ -4,6 +4,7 @@ import os.log import XCTest @available(iOS 17.0, *) +@MainActor class ShopifyAcceleratedCheckoutsTests: XCTestCase { var originalLogLevel: LogLevel! diff --git a/platforms/swift/Tests/ShopifyCheckoutKitTests/SwiftUITests.swift b/platforms/swift/Tests/ShopifyCheckoutKitTests/SwiftUITests.swift index a091378c..e8894b2e 100644 --- a/platforms/swift/Tests/ShopifyCheckoutKitTests/SwiftUITests.swift +++ b/platforms/swift/Tests/ShopifyCheckoutKitTests/SwiftUITests.swift @@ -6,8 +6,8 @@ class CheckoutViewControllerTests: XCTestCase { var checkoutURL: URL! var checkoutViewController: CheckoutViewController! - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() checkoutURL = URL(string: "https://www.shopify.com") checkoutViewController = CheckoutViewController(checkout: checkoutURL) } @@ -22,8 +22,8 @@ class ShopifyCheckoutTests: XCTestCase { var checkoutURL: URL! var shopifyCheckout: ShopifyCheckout! - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() checkoutURL = URL(string: "https://www.shopify.com") shopifyCheckout = ShopifyCheckout(checkout: checkoutURL) } @@ -65,8 +65,8 @@ class CheckoutConfigurableTests: XCTestCase { var checkoutURL: URL! var shopifyCheckout: ShopifyCheckout! - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() checkoutURL = URL(string: "https://www.shopify.com") shopifyCheckout = ShopifyCheckout(checkout: checkoutURL) } diff --git a/platforms/swift/api/ShopifyCheckoutKit.json b/platforms/swift/api/ShopifyCheckoutKit.json index 202b919e..e9ce7ca4 100644 --- a/platforms/swift/api/ShopifyCheckoutKit.json +++ b/platforms/swift/api/ShopifyCheckoutKit.json @@ -2628,6 +2628,20 @@ "usr": "s:SQ", "mangledName": "$sSQ" }, + { + "kind": "Conformance", + "name": "Sendable", + "printedName": "Sendable", + "usr": "s:s8SendableP", + "mangledName": "$ss8SendableP" + }, + { + "kind": "Conformance", + "name": "SendableMetatype", + "printedName": "SendableMetatype", + "usr": "s:s16SendableMetatypeP", + "mangledName": "$ss16SendableMetatypeP" + }, { "kind": "Conformance", "name": "Copyable", @@ -5353,6 +5367,9 @@ "usr": "s:18ShopifyCheckoutKit13configurationAA13ConfigurationVvp", "mangledName": "$s18ShopifyCheckoutKit13configurationAA13ConfigurationVvp", "moduleName": "ShopifyCheckoutKit", + "declAttributes": [ + "Nonisolated" + ], "accessors": [ { "kind": "Accessor", diff --git a/platforms/swift/api/ShopifyCheckoutProtocol.json b/platforms/swift/api/ShopifyCheckoutProtocol.json index 786e479b..d7a2ba6d 100644 --- a/platforms/swift/api/ShopifyCheckoutProtocol.json +++ b/platforms/swift/api/ShopifyCheckoutProtocol.json @@ -66404,43 +66404,6 @@ ], "funcSelfKind": "NonMutating" }, - { - "kind": "Var", - "name": "hashValue", - "printedName": "hashValue", - "children": [ - { - "kind": "TypeNominal", - "name": "Int", - "printedName": "Swift.Int", - "usr": "s:Si" - } - ], - "declKind": "Var", - "usr": "s:23ShopifyCheckoutProtocol8JSONNullC9hashValueSivp", - "mangledName": "$s23ShopifyCheckoutProtocol8JSONNullC9hashValueSivp", - "moduleName": "ShopifyCheckoutProtocol", - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "Int", - "printedName": "Swift.Int", - "usr": "s:Si" - } - ], - "declKind": "Accessor", - "usr": "s:23ShopifyCheckoutProtocol8JSONNullC9hashValueSivg", - "mangledName": "$s23ShopifyCheckoutProtocol8JSONNullC9hashValueSivg", - "moduleName": "ShopifyCheckoutProtocol", - "accessorKind": "get" - } - ] - }, { "kind": "Function", "name": "hash", @@ -66463,6 +66426,9 @@ "usr": "s:23ShopifyCheckoutProtocol8JSONNullC4hash4intoys6HasherVz_tF", "mangledName": "$s23ShopifyCheckoutProtocol8JSONNullC4hash4intoys6HasherVz_tF", "moduleName": "ShopifyCheckoutProtocol", + "declAttributes": [ + "Final" + ], "funcSelfKind": "NonMutating" }, { @@ -66532,14 +66498,65 @@ "usr": "s:23ShopifyCheckoutProtocol8JSONNullC6encode2toys7Encoder_p_tKF", "mangledName": "$s23ShopifyCheckoutProtocol8JSONNullC6encode2toys7Encoder_p_tKF", "moduleName": "ShopifyCheckoutProtocol", + "declAttributes": [ + "Final" + ], "throwing": true, "funcSelfKind": "NonMutating" + }, + { + "kind": "Var", + "name": "hashValue", + "printedName": "hashValue", + "children": [ + { + "kind": "TypeNominal", + "name": "Int", + "printedName": "Swift.Int", + "usr": "s:Si" + } + ], + "declKind": "Var", + "usr": "s:23ShopifyCheckoutProtocol8JSONNullC9hashValueSivp", + "mangledName": "$s23ShopifyCheckoutProtocol8JSONNullC9hashValueSivp", + "moduleName": "ShopifyCheckoutProtocol", + "implicit": true, + "declAttributes": [ + "Final" + ], + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "Int", + "printedName": "Swift.Int", + "usr": "s:Si" + } + ], + "declKind": "Accessor", + "usr": "s:23ShopifyCheckoutProtocol8JSONNullC9hashValueSivg", + "mangledName": "$s23ShopifyCheckoutProtocol8JSONNullC9hashValueSivg", + "moduleName": "ShopifyCheckoutProtocol", + "implicit": true, + "declAttributes": [ + "Final" + ], + "accessorKind": "get" + } + ] } ], "declKind": "Class", "usr": "s:23ShopifyCheckoutProtocol8JSONNullC", "mangledName": "$s23ShopifyCheckoutProtocol8JSONNullC", "moduleName": "ShopifyCheckoutProtocol", + "declAttributes": [ + "Final" + ], "conformances": [ { "kind": "Conformance", @@ -66562,6 +66579,13 @@ "usr": "s:SH", "mangledName": "$sSH" }, + { + "kind": "Conformance", + "name": "Sendable", + "printedName": "Sendable", + "usr": "s:s8SendableP", + "mangledName": "$ss8SendableP" + }, { "kind": "Conformance", "name": "Equatable", @@ -66569,6 +66593,13 @@ "usr": "s:SQ", "mangledName": "$sSQ" }, + { + "kind": "Conformance", + "name": "SendableMetatype", + "printedName": "SendableMetatype", + "usr": "s:s16SendableMetatypeP", + "mangledName": "$ss16SendableMetatypeP" + }, { "kind": "Conformance", "name": "Copyable", @@ -66685,6 +66716,9 @@ "usr": "s:23ShopifyCheckoutProtocol7JSONAnyC6encode2toys7Encoder_p_tKF", "mangledName": "$s23ShopifyCheckoutProtocol7JSONAnyC6encode2toys7Encoder_p_tKF", "moduleName": "ShopifyCheckoutProtocol", + "declAttributes": [ + "Final" + ], "throwing": true, "funcSelfKind": "NonMutating" } @@ -66693,6 +66727,9 @@ "usr": "s:23ShopifyCheckoutProtocol7JSONAnyC", "mangledName": "$s23ShopifyCheckoutProtocol7JSONAnyC", "moduleName": "ShopifyCheckoutProtocol", + "declAttributes": [ + "Final" + ], "conformances": [ { "kind": "Conformance", @@ -66708,6 +66745,20 @@ "usr": "s:SE", "mangledName": "$sSE" }, + { + "kind": "Conformance", + "name": "Sendable", + "printedName": "Sendable", + "usr": "s:s8SendableP", + "mangledName": "$ss8SendableP" + }, + { + "kind": "Conformance", + "name": "SendableMetatype", + "printedName": "SendableMetatype", + "usr": "s:s16SendableMetatypeP", + "mangledName": "$ss16SendableMetatypeP" + }, { "kind": "Conformance", "name": "Copyable",