From 3ee14ea4cc7cf43d8c0f833a77a94c47fded8e22 Mon Sep 17 00:00:00 2001 From: Go Takagi <15936908+shimastripe@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:18:43 +0900 Subject: [PATCH 1/5] Enable swift 6 mode --- .../project.pbxproj | 4 +-- Package.swift | 28 ++++--------------- Sources/IAPClient/CredentialClient.swift | 2 +- Sources/IAPClient/RootCertificateClient.swift | 2 +- Sources/IAPClient/SignedDataVerifier+.swift | 2 +- .../AppStoreServerClientInterface.swift | 2 +- .../IAPInterface/Model/AutoRenewStatus+.swift | 2 +- .../Model/ExpirationIntent+.swift | 2 +- .../Model/JWSTransactionDecodedPayload+.swift | 2 +- .../Model/NotificationHistoryModel.swift | 6 ++-- Sources/IAPInterface/Model/OfferType+.swift | 2 +- .../Model/PriceIncreaseStatus+.swift | 2 +- .../Model/RevocationReason+.swift | 2 +- .../Model/ServerEnvironment.swift | 2 +- Sources/IAPInterface/Model/Status+.swift | 2 +- .../Model/SubscriptionStatus.swift | 8 +++--- .../Model/TransactionHistory.swift | 4 +-- .../RootCertificateClientInterface.swift | 4 +-- 18 files changed, 31 insertions(+), 47 deletions(-) diff --git a/App/InAppPurchaseViewer/InAppPurchaseViewer.xcodeproj/project.pbxproj b/App/InAppPurchaseViewer/InAppPurchaseViewer.xcodeproj/project.pbxproj index fbbf85f..dbbad6c 100644 --- a/App/InAppPurchaseViewer/InAppPurchaseViewer.xcodeproj/project.pbxproj +++ b/App/InAppPurchaseViewer/InAppPurchaseViewer.xcodeproj/project.pbxproj @@ -216,6 +216,7 @@ ONLY_ACTIVE_ARCH = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 6.0; }; name = Debug; }; @@ -269,6 +270,7 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_VERSION = 6.0; }; name = Release; }; @@ -293,7 +295,6 @@ SUPPORTED_PLATFORMS = macosx; SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -318,7 +319,6 @@ SUPPORTED_PLATFORMS = macosx; SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Package.swift b/Package.swift index 659db98..113feca 100644 --- a/Package.swift +++ b/Package.swift @@ -1,21 +1,8 @@ -// swift-tools-version: 5.10 +// swift-tools-version: 6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription -let swiftSettings: [SwiftSetting] = [ - .enableUpcomingFeature("BareSlashRegexLiterals"), - .enableUpcomingFeature("ConciseMagicFile"), - .enableUpcomingFeature("DeprecateApplicationMain"), - .enableUpcomingFeature("DisableOutwardActorInference"), - .enableUpcomingFeature("ExistentialAny"), - .enableUpcomingFeature("ForwardTrailingClosures"), - .enableUpcomingFeature("GlobalConcurrency"), - .enableUpcomingFeature("ImplicitOpenExistentials"), - .enableUpcomingFeature("ImportObjcForwardDeclarations"), - .enableUpcomingFeature("IsolatedDefaultValues"), -] - let package = Package( name: "InAppPurchaseViewer", defaultLocalization: "ja", @@ -56,8 +43,7 @@ let package = Package( dependencies: [ .product(name: "Dependencies", package: "swift-dependencies"), .product(name: "DependenciesMacros", package: "swift-dependencies"), - ], - swiftSettings: swiftSettings + ] ), .target( name: "IAPInterface", @@ -65,15 +51,13 @@ let package = Package( "IAPCore", // Use Model... .product(name: "AppStoreServerLibrary", package: "app-store-server-library-swift"), - ], - swiftSettings: swiftSettings + ] ), .target( name: "IAPModel", dependencies: [ "IAPInterface", - ], - swiftSettings: swiftSettings + ] ), .testTarget( name: "IAPModelTests", @@ -85,7 +69,6 @@ let package = Package( "IAPModel", .product(name: "Sparkle", package: "Sparkle"), ], - swiftSettings: swiftSettings, plugins: [ .plugin(name: "LicensesPlugin", package: "LicensesPlugin"), ] @@ -94,5 +77,6 @@ let package = Package( name: "IAPViewTests", dependencies: ["IAPView"] ), - ] + ], + swiftLanguageVersions: [.v6] ) diff --git a/Sources/IAPClient/CredentialClient.swift b/Sources/IAPClient/CredentialClient.swift index 8fabb45..a937866 100644 --- a/Sources/IAPClient/CredentialClient.swift +++ b/Sources/IAPClient/CredentialClient.swift @@ -8,7 +8,7 @@ import Dependencies import Foundation import IAPInterface -import KeychainAccess +@preconcurrency import KeychainAccess extension CredentialClient: DependencyKey { diff --git a/Sources/IAPClient/RootCertificateClient.swift b/Sources/IAPClient/RootCertificateClient.swift index 0dc7699..d7ab219 100644 --- a/Sources/IAPClient/RootCertificateClient.swift +++ b/Sources/IAPClient/RootCertificateClient.swift @@ -10,7 +10,7 @@ import Foundation import HTTPTypes import HTTPTypesFoundation import IAPInterface -import KeychainAccess +@preconcurrency import KeychainAccess extension RootCertificateClient: DependencyKey { public static let liveValue: RootCertificateClient = { diff --git a/Sources/IAPClient/SignedDataVerifier+.swift b/Sources/IAPClient/SignedDataVerifier+.swift index 329fb90..90bd2a3 100644 --- a/Sources/IAPClient/SignedDataVerifier+.swift +++ b/Sources/IAPClient/SignedDataVerifier+.swift @@ -8,7 +8,7 @@ import AppStoreServerLibrary import Foundation -extension VerificationError: Error {} +extension VerificationError: @retroactive Error {} extension SignedDataVerifier { diff --git a/Sources/IAPInterface/AppStoreServerClientInterface.swift b/Sources/IAPInterface/AppStoreServerClientInterface.swift index 380746d..70674f8 100644 --- a/Sources/IAPInterface/AppStoreServerClientInterface.swift +++ b/Sources/IAPInterface/AppStoreServerClientInterface.swift @@ -56,7 +56,7 @@ public struct AppStoreServerClient: Sendable { extension AppStoreServerClient: TestDependencyKey { public static let testValue = Self() public static let previewValue: AppStoreServerClient = { - let makeDate: (_ year: Int, _ month: Int, _ day: Int, _ hour: Int, _ minute: Int) -> Date? = + let makeDate: @Sendable (_ year: Int, _ month: Int, _ day: Int, _ hour: Int, _ minute: Int) -> Date? = { (year, month, day, hour, minute) in Calendar.current.date( diff --git a/Sources/IAPInterface/Model/AutoRenewStatus+.swift b/Sources/IAPInterface/Model/AutoRenewStatus+.swift index 878db6d..0a53d47 100644 --- a/Sources/IAPInterface/Model/AutoRenewStatus+.swift +++ b/Sources/IAPInterface/Model/AutoRenewStatus+.swift @@ -8,7 +8,7 @@ import AppStoreServerLibrary import Foundation -extension AutoRenewStatus: CustomStringConvertible { +extension AutoRenewStatus: @retroactive CustomStringConvertible { public var description: String { switch self { diff --git a/Sources/IAPInterface/Model/ExpirationIntent+.swift b/Sources/IAPInterface/Model/ExpirationIntent+.swift index b7bde75..812a988 100644 --- a/Sources/IAPInterface/Model/ExpirationIntent+.swift +++ b/Sources/IAPInterface/Model/ExpirationIntent+.swift @@ -8,7 +8,7 @@ import AppStoreServerLibrary import Foundation -extension ExpirationIntent: CustomStringConvertible { +extension ExpirationIntent: @retroactive CustomStringConvertible { public var description: String { switch self { diff --git a/Sources/IAPInterface/Model/JWSTransactionDecodedPayload+.swift b/Sources/IAPInterface/Model/JWSTransactionDecodedPayload+.swift index 86c2972..39bd19a 100644 --- a/Sources/IAPInterface/Model/JWSTransactionDecodedPayload+.swift +++ b/Sources/IAPInterface/Model/JWSTransactionDecodedPayload+.swift @@ -7,7 +7,7 @@ import AppStoreServerLibrary -extension JWSTransactionDecodedPayload: Identifiable { +extension JWSTransactionDecodedPayload: @retroactive Identifiable { public var id: String? { transactionId } diff --git a/Sources/IAPInterface/Model/NotificationHistoryModel.swift b/Sources/IAPInterface/Model/NotificationHistoryModel.swift index 1e05622..2d03ed7 100644 --- a/Sources/IAPInterface/Model/NotificationHistoryModel.swift +++ b/Sources/IAPInterface/Model/NotificationHistoryModel.swift @@ -5,10 +5,10 @@ // Created by shimastripe on 2024/02/10. // -import AppStoreServerLibrary // For Model +@preconcurrency import AppStoreServerLibrary // For Model import Foundation -public struct NotificationHistoryModel: Codable, Hashable { +public struct NotificationHistoryModel: Codable, Hashable, Sendable { public var paginationToken: String? @@ -25,7 +25,7 @@ public struct NotificationHistoryModel: Codable, Hashable { } } -public struct NotificationHistoryItem: Identifiable, Codable, Hashable { +public struct NotificationHistoryItem: Identifiable, Codable, Hashable, Sendable { public struct ID: RawRepresentable, Hashable, Sendable, Codable, ExpressibleByStringLiteral { public let rawValue: String diff --git a/Sources/IAPInterface/Model/OfferType+.swift b/Sources/IAPInterface/Model/OfferType+.swift index e8b1846..b04c785 100644 --- a/Sources/IAPInterface/Model/OfferType+.swift +++ b/Sources/IAPInterface/Model/OfferType+.swift @@ -8,7 +8,7 @@ import AppStoreServerLibrary import Foundation -extension OfferType: CustomStringConvertible { +extension OfferType: @retroactive CustomStringConvertible { public var description: String { switch self { diff --git a/Sources/IAPInterface/Model/PriceIncreaseStatus+.swift b/Sources/IAPInterface/Model/PriceIncreaseStatus+.swift index dc987b1..257ea10 100644 --- a/Sources/IAPInterface/Model/PriceIncreaseStatus+.swift +++ b/Sources/IAPInterface/Model/PriceIncreaseStatus+.swift @@ -8,7 +8,7 @@ import AppStoreServerLibrary import Foundation -extension PriceIncreaseStatus: CustomStringConvertible { +extension PriceIncreaseStatus: @retroactive CustomStringConvertible { public var description: String { switch self { diff --git a/Sources/IAPInterface/Model/RevocationReason+.swift b/Sources/IAPInterface/Model/RevocationReason+.swift index 64763e2..d297d54 100644 --- a/Sources/IAPInterface/Model/RevocationReason+.swift +++ b/Sources/IAPInterface/Model/RevocationReason+.swift @@ -7,7 +7,7 @@ import AppStoreServerLibrary -extension RevocationReason: CustomStringConvertible { +extension RevocationReason: @retroactive CustomStringConvertible { public var description: String { switch self { diff --git a/Sources/IAPInterface/Model/ServerEnvironment.swift b/Sources/IAPInterface/Model/ServerEnvironment.swift index d546749..c42f686 100644 --- a/Sources/IAPInterface/Model/ServerEnvironment.swift +++ b/Sources/IAPInterface/Model/ServerEnvironment.swift @@ -7,7 +7,7 @@ import Foundation -public enum ServerEnvironment: Identifiable, Hashable, CustomStringConvertible, CaseIterable { +public enum ServerEnvironment: Identifiable, Hashable, CustomStringConvertible, CaseIterable, Sendable { case sandbox case production diff --git a/Sources/IAPInterface/Model/Status+.swift b/Sources/IAPInterface/Model/Status+.swift index 4e40124..1e7e71d 100644 --- a/Sources/IAPInterface/Model/Status+.swift +++ b/Sources/IAPInterface/Model/Status+.swift @@ -8,7 +8,7 @@ import AppStoreServerLibrary import SwiftUI -extension Status: CustomStringConvertible { +extension Status: @retroactive CustomStringConvertible { public var description: String { switch self { case .active: diff --git a/Sources/IAPInterface/Model/SubscriptionStatus.swift b/Sources/IAPInterface/Model/SubscriptionStatus.swift index 00a9f45..cad278c 100644 --- a/Sources/IAPInterface/Model/SubscriptionStatus.swift +++ b/Sources/IAPInterface/Model/SubscriptionStatus.swift @@ -5,10 +5,10 @@ // Created by shimastripe on 2024/02/22. // -import AppStoreServerLibrary // For Model +@preconcurrency import AppStoreServerLibrary // For Model import Foundation -public struct SubscriptionStatus: Codable, Hashable { +public struct SubscriptionStatus: Codable, Hashable, Sendable { public let environment: Environment? @@ -28,7 +28,7 @@ public struct SubscriptionStatus: Codable, Hashable { } } -public struct SubscriptionGroup: Codable, Hashable, Identifiable { +public struct SubscriptionGroup: Codable, Hashable, Identifiable, Sendable { public let subscriptionGroupIdentifier: String? @@ -47,7 +47,7 @@ public struct SubscriptionGroup: Codable, Hashable, Identifiable { } } -public struct LastTransaction: Codable, Hashable, Identifiable { +public struct LastTransaction: Codable, Hashable, Identifiable, Sendable { public let status: Status? diff --git a/Sources/IAPInterface/Model/TransactionHistory.swift b/Sources/IAPInterface/Model/TransactionHistory.swift index c9aba3d..ae2b7a4 100644 --- a/Sources/IAPInterface/Model/TransactionHistory.swift +++ b/Sources/IAPInterface/Model/TransactionHistory.swift @@ -5,10 +5,10 @@ // Created by shimastripe on 2024/02/24. // -import AppStoreServerLibrary // For Model +@preconcurrency import AppStoreServerLibrary // For Model import Foundation -public struct TransactionHistory: Codable, Hashable { +public struct TransactionHistory: Codable, Hashable, Sendable { public var revision: String? diff --git a/Sources/IAPInterface/RootCertificateClientInterface.swift b/Sources/IAPInterface/RootCertificateClientInterface.swift index 404c032..8adc8ef 100644 --- a/Sources/IAPInterface/RootCertificateClientInterface.swift +++ b/Sources/IAPInterface/RootCertificateClientInterface.swift @@ -30,12 +30,12 @@ extension RootCertificateClient: TestDependencyKey { public static let testValue = Self() public static let previewValue: RootCertificateClient = .init( fetch: { - unimplemented() + unimplemented(placeholder: Data()) }, get: { Data() }, remove: { - unimplemented() + unimplemented(placeholder: ()) }) } From b8d9ae58a72801fc7340340593bb136f4554f3ec Mon Sep 17 00:00:00 2001 From: Go Takagi <15936908+shimastripe@users.noreply.github.com> Date: Thu, 12 Sep 2024 02:33:14 +0900 Subject: [PATCH 2/5] Format --- .../InAppPurchaseViewerApp.swift | 5 +++-- App/Package.swift | 8 ++++---- Package.swift | 4 ++-- .../AppStoreServerClientInterface.swift | 15 ++++++++------- .../IAPInterface/Model/ServerEnvironment.swift | 4 +++- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/App/InAppPurchaseViewer/InAppPurchaseViewer/InAppPurchaseViewerApp.swift b/App/InAppPurchaseViewer/InAppPurchaseViewer/InAppPurchaseViewerApp.swift index 27a68ba..d9ddfe8 100644 --- a/App/InAppPurchaseViewer/InAppPurchaseViewer/InAppPurchaseViewerApp.swift +++ b/App/InAppPurchaseViewer/InAppPurchaseViewer/InAppPurchaseViewerApp.swift @@ -25,8 +25,9 @@ struct InAppPurchaseViewerApp: App { } .commands { CommandGroup(after: .appInfo) { - Button("Check for Updates...", - action: updaterController.updater.checkForUpdates) + Button( + "Check for Updates...", + action: updaterController.updater.checkForUpdates) } } Settings { diff --git a/App/Package.swift b/App/Package.swift index 24f66a6..f633a64 100644 --- a/App/Package.swift +++ b/App/Package.swift @@ -5,7 +5,7 @@ import PackageDescription let package = Package( - name: "client", - products: [], - targets: [] -) \ No newline at end of file + name: "client", + products: [], + targets: [] +) diff --git a/Package.swift b/Package.swift index 113feca..ac023ce 100644 --- a/Package.swift +++ b/Package.swift @@ -56,7 +56,7 @@ let package = Package( .target( name: "IAPModel", dependencies: [ - "IAPInterface", + "IAPInterface" ] ), .testTarget( @@ -70,7 +70,7 @@ let package = Package( .product(name: "Sparkle", package: "Sparkle"), ], plugins: [ - .plugin(name: "LicensesPlugin", package: "LicensesPlugin"), + .plugin(name: "LicensesPlugin", package: "LicensesPlugin") ] ), .testTarget( diff --git a/Sources/IAPInterface/AppStoreServerClientInterface.swift b/Sources/IAPInterface/AppStoreServerClientInterface.swift index 70674f8..21182cd 100644 --- a/Sources/IAPInterface/AppStoreServerClientInterface.swift +++ b/Sources/IAPInterface/AppStoreServerClientInterface.swift @@ -56,13 +56,14 @@ public struct AppStoreServerClient: Sendable { extension AppStoreServerClient: TestDependencyKey { public static let testValue = Self() public static let previewValue: AppStoreServerClient = { - let makeDate: @Sendable (_ year: Int, _ month: Int, _ day: Int, _ hour: Int, _ minute: Int) -> Date? = - { - (year, month, day, hour, minute) in - Calendar.current.date( - from: .init( - year: year, month: month, day: day, hour: hour, minute: minute)) - } + let makeDate: + @Sendable (_ year: Int, _ month: Int, _ day: Int, _ hour: Int, _ minute: Int) -> Date? = + { + (year, month, day, hour, minute) in + Calendar.current.date( + from: .init( + year: year, month: month, day: day, hour: hour, minute: minute)) + } return .init( fetchNotificationHistory: { _, _, _, _, _, _, _ in diff --git a/Sources/IAPInterface/Model/ServerEnvironment.swift b/Sources/IAPInterface/Model/ServerEnvironment.swift index c42f686..23778f3 100644 --- a/Sources/IAPInterface/Model/ServerEnvironment.swift +++ b/Sources/IAPInterface/Model/ServerEnvironment.swift @@ -7,7 +7,9 @@ import Foundation -public enum ServerEnvironment: Identifiable, Hashable, CustomStringConvertible, CaseIterable, Sendable { +public enum ServerEnvironment: Identifiable, Hashable, CustomStringConvertible, CaseIterable, + Sendable +{ case sandbox case production From 8912422455a03e6e99f4283ecc66028bd3b0d832 Mon Sep 17 00:00:00 2001 From: Go Takagi <15936908+shimastripe@users.noreply.github.com> Date: Thu, 12 Sep 2024 02:33:24 +0900 Subject: [PATCH 3/5] Add Makefile --- .../project.pbxproj | 23 +++++++++++++++++++ Makefile | 3 +++ Package.swift | 1 - 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/App/InAppPurchaseViewer/InAppPurchaseViewer.xcodeproj/project.pbxproj b/App/InAppPurchaseViewer/InAppPurchaseViewer.xcodeproj/project.pbxproj index dbbad6c..858d7ea 100644 --- a/App/InAppPurchaseViewer/InAppPurchaseViewer.xcodeproj/project.pbxproj +++ b/App/InAppPurchaseViewer/InAppPurchaseViewer.xcodeproj/project.pbxproj @@ -82,6 +82,7 @@ isa = PBXNativeTarget; buildConfigurationList = 458FE1652B6E239700798686 /* Build configuration list for PBXNativeTarget "InAppPurchaseViewer" */; buildPhases = ( + 45A8B3AC2C920C25004E6CF6 /* Run swift-format */, 458FE1522B6E239600798686 /* Sources */, 458FE1532B6E239600798686 /* Frameworks */, 458FE1542B6E239600798686 /* Resources */, @@ -146,6 +147,28 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 45A8B3AC2C920C25004E6CF6 /* Run swift-format */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Run swift-format"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "cd ../../\nmake format\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 458FE1522B6E239600798686 /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fe4f438 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +.PHONY: format +format: + xcrun --sdk macosx swift-format swift-format -p -r -i . diff --git a/Package.swift b/Package.swift index ac023ce..5dbaa28 100644 --- a/Package.swift +++ b/Package.swift @@ -21,7 +21,6 @@ let package = Package( .package(url: "https://github.com/sparkle-project/Sparkle", exact: "2.6.4"), .package(url: "https://github.com/pointfreeco/swift-dependencies", exact: "1.3.9"), .package(url: "https://github.com/apple/swift-http-types", exact: "1.3.0"), - .package(url: "https://github.com/apple/swift-format", exact: "510.1.0"), ], targets: [ .target( From ebf3e5a0f91c9d66934fd5b54404470e733ac8a8 Mon Sep 17 00:00:00 2001 From: Go Takagi <15936908+shimastripe@users.noreply.github.com> Date: Thu, 12 Sep 2024 02:47:02 +0900 Subject: [PATCH 4/5] Bump Xcode version for CodeQL --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 9afcdcb..6f057a5 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -11,7 +11,7 @@ jobs: name: Analyze runs-on: macos-14 env: - DEVELOPER_DIR: "/Applications/Xcode_15.4.0.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode_16_beta_6.app/Contents/Developer" timeout-minutes: 120 permissions: security-events: write From 3028abb4379653f83aa3bc8333d4c6591e5ba4da Mon Sep 17 00:00:00 2001 From: Go Takagi <15936908+shimastripe@users.noreply.github.com> Date: Thu, 12 Sep 2024 02:59:18 +0900 Subject: [PATCH 5/5] Update readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a86a9e5..061d210 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Get the statuses for all of a customer’s auto-renewable subscriptions in your ### Development Environment -- macOS 14 Sonoma -- Xcode 15.4 -- Swift 5.10 +- macOS 15 Sequoia +- Xcode 16.0 +- Swift 6.0 - Sandbox enabled