From a12606d930742bc95a4d59b6c7cde0dce8216088 Mon Sep 17 00:00:00 2001 From: "zunda.dev@gmail.com" Date: Tue, 27 May 2025 17:03:13 +0900 Subject: [PATCH 1/7] update swift version to v6 --- Package.swift | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/Package.swift b/Package.swift index f817c35f..9a57089a 100644 --- a/Package.swift +++ b/Package.swift @@ -1,19 +1,11 @@ -// swift-tools-version:5.1 +// swift-tools-version:6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription -#if swift(>=5.9) -let platforms: [PackageDescription.SupportedPlatform] = [.macOS(.v10_13), .iOS(.v12), .watchOS(.v4), .tvOS(.v12)] -#elseif swift(>=5.7) -let platforms: [PackageDescription.SupportedPlatform] = [.macOS(.v10_13), .iOS(.v11), .watchOS(.v4), .tvOS(.v11)] -#elseif swift(>=5.0) -let platforms: [PackageDescription.SupportedPlatform]? = nil -#endif - let package = Package( name: "XMLCoder", - platforms: platforms, + platforms: [.macOS(.v10_13), .iOS(.v12), .watchOS(.v4), .tvOS(.v12)], products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. .library( @@ -21,16 +13,14 @@ let package = Package( targets: ["XMLCoder"] ), ], - dependencies: [ - // Dependencies declare other packages that this package depends on. - // .package(url: /* package url */, from: "1.0.0"), - ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages which this package depends on. .target( name: "XMLCoder", - dependencies: [] + swiftSettings: [ + .swiftLanguageMode(.v5) + ] ), .testTarget( name: "XMLCoderTests", From c7d36340e0db6611ba501b3ae1d537e2e733b8b2 Mon Sep 17 00:00:00 2001 From: "zunda.dev@gmail.com" Date: Tue, 27 May 2025 17:03:19 +0900 Subject: [PATCH 2/7] add Sendable --- Sources/XMLCoder/Encoder/XMLEncoder.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/XMLCoder/Encoder/XMLEncoder.swift b/Sources/XMLCoder/Encoder/XMLEncoder.swift index 23efd3d0..ba9bfdf9 100644 --- a/Sources/XMLCoder/Encoder/XMLEncoder.swift +++ b/Sources/XMLCoder/Encoder/XMLEncoder.swift @@ -13,7 +13,7 @@ open class XMLEncoder { // MARK: Options /// The formatting of the output XML data. - public struct OutputFormatting: OptionSet { + public struct OutputFormatting: OptionSet, Sendable { /// The format's default value. public let rawValue: UInt @@ -39,7 +39,7 @@ open class XMLEncoder { } /// A node's encoding type. Specifies how a node will be encoded. - public enum NodeEncoding { + public enum NodeEncoding: Sendable { case attribute case element case both From 792f415bde6c0ae329f71d986f3077ae02f99a98 Mon Sep 17 00:00:00 2001 From: "zunda.dev@gmail.com" Date: Tue, 27 May 2025 17:04:20 +0900 Subject: [PATCH 3/7] fix indent --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 9a57089a..fab7c78b 100644 --- a/Package.swift +++ b/Package.swift @@ -19,7 +19,7 @@ let package = Package( .target( name: "XMLCoder", swiftSettings: [ - .swiftLanguageMode(.v5) + .swiftLanguageMode(.v5) ] ), .testTarget( From 90abfa359a15cc70acccdf8b1b789cf87c87cfb3 Mon Sep 17 00:00:00 2001 From: "zunda.dev@gmail.com" Date: Tue, 27 May 2025 17:04:32 +0900 Subject: [PATCH 4/7] add editorconfig --- .editorconfig | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..c579b3d8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# editorconfig.org + +root = true + +[*] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true \ No newline at end of file From 164e216468d4e1c5fdedc164de0f7c634a52f2e8 Mon Sep 17 00:00:00 2001 From: "zunda.dev@gmail.com" Date: Tue, 27 May 2025 17:15:55 +0900 Subject: [PATCH 5/7] remove ISO8601DateFormatter --- Package.swift | 12 ++++++----- .../XMLCoder/Auxiliaries/Box/DateBox.swift | 16 ++++---------- .../Auxiliaries/ISO8601DateFormatter.swift | 21 ------------------- Sources/XMLCoder/Decoder/XMLDecoder.swift | 1 - Sources/XMLCoder/Encoder/XMLEncoder.swift | 1 - Tests/XMLCoderTests/CombineTests.swift | 1 - 6 files changed, 11 insertions(+), 41 deletions(-) delete mode 100644 Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift diff --git a/Package.swift b/Package.swift index fab7c78b..5e934ef9 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,12 @@ import PackageDescription let package = Package( name: "XMLCoder", - platforms: [.macOS(.v10_13), .iOS(.v12), .watchOS(.v4), .tvOS(.v12)], + platforms: [ + .macOS(.v12), + .iOS(.v15), + .watchOS(.v8), + .tvOS(.v15) + ], products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. .library( @@ -17,10 +22,7 @@ let package = Package( // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages which this package depends on. .target( - name: "XMLCoder", - swiftSettings: [ - .swiftLanguageMode(.v5) - ] + name: "XMLCoder" ), .testTarget( name: "XMLCoderTests", diff --git a/Sources/XMLCoder/Auxiliaries/Box/DateBox.swift b/Sources/XMLCoder/Auxiliaries/Box/DateBox.swift index a9d18d4b..02640c8d 100644 --- a/Sources/XMLCoder/Auxiliaries/Box/DateBox.swift +++ b/Sources/XMLCoder/Auxiliaries/Box/DateBox.swift @@ -43,14 +43,10 @@ struct DateBox: Equatable { } init?(iso8601 string: String) { - if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) { - guard let unboxed = _iso8601Formatter.date(from: string) else { - return nil - } - self.init(unboxed, format: .iso8601) - } else { - fatalError("ISO8601DateFormatter is unavailable on this platform.") + guard let unboxed = try? Date(string, strategy: .iso8601) else { + return nil } + self.init(unboxed, format: .iso8601) } init?(xmlString: String, formatter: DateFormatter) { @@ -69,11 +65,7 @@ struct DateBox: Equatable { let milliseconds = unboxed.timeIntervalSince1970 * 1000.0 return milliseconds.description case .iso8601: - if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) { - return _iso8601Formatter.string(from: self.unboxed) - } else { - fatalError("ISO8601DateFormatter is unavailable on this platform.") - } + return Date.ISO8601FormatStyle().format(self.unboxed) case let .formatter(formatter): return formatter.string(from: unboxed) } diff --git a/Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift b/Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift deleted file mode 100644 index 08c248bf..00000000 --- a/Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2017-2020 Shawn Moore and XMLCoder contributors -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT -// -// Created by Shawn Moore on 11/21/17. -// - -import Foundation - -/// Shared ISO8601 Date Formatter -/// NOTE: This value is implicitly lazy and _must_ be lazy. We're compiled -/// against the latest SDK (w/ ISO8601DateFormatter), but linked against -/// whichever Foundation the user has. ISO8601DateFormatter might not exist, so -/// we better not hit this code path on an older OS. -@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) -var _iso8601Formatter: ISO8601DateFormatter = { - let formatter = ISO8601DateFormatter() - formatter.formatOptions = .withInternetDateTime - return formatter -}() diff --git a/Sources/XMLCoder/Decoder/XMLDecoder.swift b/Sources/XMLCoder/Decoder/XMLDecoder.swift index 1f67b269..f8473118 100644 --- a/Sources/XMLCoder/Decoder/XMLDecoder.swift +++ b/Sources/XMLCoder/Decoder/XMLDecoder.swift @@ -26,7 +26,6 @@ open class XMLDecoder { case millisecondsSince1970 /// Decode the `Date` as an ISO-8601-formatted string (in RFC 3339 format). - @available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) case iso8601 /// Decode the `Date` as a string parsed by the given formatter. diff --git a/Sources/XMLCoder/Encoder/XMLEncoder.swift b/Sources/XMLCoder/Encoder/XMLEncoder.swift index ba9bfdf9..7c7db8fb 100644 --- a/Sources/XMLCoder/Encoder/XMLEncoder.swift +++ b/Sources/XMLCoder/Encoder/XMLEncoder.swift @@ -59,7 +59,6 @@ open class XMLEncoder { case millisecondsSince1970 /// Encode the `Date` as an ISO-8601-formatted string (in RFC 3339 format). - @available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) case iso8601 /// Encode the `Date` as a string formatted by the given formatter. diff --git a/Tests/XMLCoderTests/CombineTests.swift b/Tests/XMLCoderTests/CombineTests.swift index 04f8d7d9..c47ff245 100644 --- a/Tests/XMLCoderTests/CombineTests.swift +++ b/Tests/XMLCoderTests/CombineTests.swift @@ -34,7 +34,6 @@ final class CustomEncoder: XMLEncoder { } } -@available(iOS 13.0, macOS 10.15.0, tvOS 13.0, watchOS 6.0, *) final class CombineTests: XCTestCase { func testDecode() { var foo: Foo? From 6c9a9583daeedaf40a6a0bd295ac2a0956f4b280 Mon Sep 17 00:00:00 2001 From: "zunda.dev@gmail.com" Date: Tue, 27 May 2025 17:50:05 +0900 Subject: [PATCH 6/7] add @Sendable --- Sources/XMLCoder/Encoder/XMLEncoder.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/XMLCoder/Encoder/XMLEncoder.swift b/Sources/XMLCoder/Encoder/XMLEncoder.swift index 7c7db8fb..cc49dd9f 100644 --- a/Sources/XMLCoder/Encoder/XMLEncoder.swift +++ b/Sources/XMLCoder/Encoder/XMLEncoder.swift @@ -233,7 +233,7 @@ open class XMLEncoder { public typealias NodeEncodingStrategies = NodeEncodingStrategy public typealias XMLNodeEncoderClosure = (CodingKey) -> NodeEncoding? - public typealias XMLEncodingClosure = (Encodable.Type, Encoder) -> XMLNodeEncoderClosure + public typealias XMLEncodingClosure = @Sendable (Encodable.Type, Encoder) -> XMLNodeEncoderClosure /// Set of strategies to use for encoding of nodes. public enum NodeEncodingStrategy { From 376c098e8939eb6fee2bbfa99f7541e41285b255 Mon Sep 17 00:00:00 2001 From: "zunda.dev@gmail.com" Date: Tue, 3 Jun 2025 20:02:00 +0900 Subject: [PATCH 7/7] add Sendable --- Sources/XMLCoder/Auxiliaries/Attribute.swift | 1 + Sources/XMLCoder/Auxiliaries/Element.swift | 1 + Sources/XMLCoder/Auxiliaries/ElementAndAttribute.swift | 1 + Tests/XMLCoderTests/AdvancedFeatures/PropertyWrappersTest.swift | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/XMLCoder/Auxiliaries/Attribute.swift b/Sources/XMLCoder/Auxiliaries/Attribute.swift index 6f6dcdc5..a908bee0 100644 --- a/Sources/XMLCoder/Auxiliaries/Attribute.swift +++ b/Sources/XMLCoder/Auxiliaries/Attribute.swift @@ -40,6 +40,7 @@ extension Attribute: Codable where Value: Codable { extension Attribute: Equatable where Value: Equatable {} extension Attribute: Hashable where Value: Hashable {} +extension Attribute: Sendable where Value: Sendable {} extension Attribute: ExpressibleByIntegerLiteral where Value: ExpressibleByIntegerLiteral { public typealias IntegerLiteralType = Value.IntegerLiteralType diff --git a/Sources/XMLCoder/Auxiliaries/Element.swift b/Sources/XMLCoder/Auxiliaries/Element.swift index 57a2b7dd..8728e4ac 100644 --- a/Sources/XMLCoder/Auxiliaries/Element.swift +++ b/Sources/XMLCoder/Auxiliaries/Element.swift @@ -40,3 +40,4 @@ extension Element: Codable where Value: Codable { extension Element: Equatable where Value: Equatable {} extension Element: Hashable where Value: Hashable {} +extension Element: Sendable where Value: Sendable {} diff --git a/Sources/XMLCoder/Auxiliaries/ElementAndAttribute.swift b/Sources/XMLCoder/Auxiliaries/ElementAndAttribute.swift index 69d6c02b..b04cfc56 100644 --- a/Sources/XMLCoder/Auxiliaries/ElementAndAttribute.swift +++ b/Sources/XMLCoder/Auxiliaries/ElementAndAttribute.swift @@ -41,3 +41,4 @@ extension ElementAndAttribute: Codable where Value: Codable { extension ElementAndAttribute: Equatable where Value: Equatable {} extension ElementAndAttribute: Hashable where Value: Hashable {} +extension ElementAndAttribute: Sendable where Value: Sendable {} diff --git a/Tests/XMLCoderTests/AdvancedFeatures/PropertyWrappersTest.swift b/Tests/XMLCoderTests/AdvancedFeatures/PropertyWrappersTest.swift index ef3cb4a1..60f0162b 100644 --- a/Tests/XMLCoderTests/AdvancedFeatures/PropertyWrappersTest.swift +++ b/Tests/XMLCoderTests/AdvancedFeatures/PropertyWrappersTest.swift @@ -9,7 +9,7 @@ import Foundation import XCTest import XMLCoder -private struct Book: Codable, Equatable { +private struct Book: Codable, Equatable, Sendable { @Attribute var id: Int @Element var name: String @ElementAndAttribute var authorID: Int