From e101013956eea034e601c694f31e40960a93a648 Mon Sep 17 00:00:00 2001 From: leogdion Date: Thu, 17 Jul 2025 10:39:15 -0400 Subject: [PATCH 1/7] making fixes for swift 6 on XMLCoder --- Sources/XMLCoder/Auxiliaries/Box/DateBox.swift | 6 +++--- .../Auxiliaries/ISO8601DateFormatter.swift | 18 +++++++----------- .../XMLCoder/Encoder/DynamicNodeEncoding.swift | 2 +- Sources/XMLCoder/Encoder/XMLEncoder.swift | 8 ++++---- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Sources/XMLCoder/Auxiliaries/Box/DateBox.swift b/Sources/XMLCoder/Auxiliaries/Box/DateBox.swift index a9d18d4b..c18957b5 100644 --- a/Sources/XMLCoder/Auxiliaries/Box/DateBox.swift +++ b/Sources/XMLCoder/Auxiliaries/Box/DateBox.swift @@ -8,7 +8,7 @@ import Foundation -struct DateBox: Equatable { +struct DateBox: Equatable, Sendable { enum Format: Equatable { case secondsSince1970 case millisecondsSince1970 @@ -44,7 +44,7 @@ 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 { + guard let unboxed = ISO8601DateFormatter.xmlCoderFormatter().date(from: string) else { return nil } self.init(unboxed, format: .iso8601) @@ -70,7 +70,7 @@ struct DateBox: Equatable { 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) + return ISO8601DateFormatter.xmlCoderFormatter().string(from: self.unboxed) } else { fatalError("ISO8601DateFormatter is unavailable on this platform.") } diff --git a/Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift b/Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift index 08c248bf..a431b23e 100644 --- a/Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift +++ b/Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift @@ -8,14 +8,10 @@ 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 -}() +extension ISO8601DateFormatter { + static func xmlCoderFormatter() -> ISO8601DateFormatter { + let formatter = ISO8601DateFormatter() + formatter.formatOptions = .withInternetDateTime + return formatter + } +} \ No newline at end of file diff --git a/Sources/XMLCoder/Encoder/DynamicNodeEncoding.swift b/Sources/XMLCoder/Encoder/DynamicNodeEncoding.swift index 79cbec6f..bbb79fa8 100644 --- a/Sources/XMLCoder/Encoder/DynamicNodeEncoding.swift +++ b/Sources/XMLCoder/Encoder/DynamicNodeEncoding.swift @@ -40,7 +40,7 @@ ``` */ -public protocol DynamicNodeEncoding: Encodable { +public protocol DynamicNodeEncoding: Encodable, Sendable { static func nodeEncoding(for key: CodingKey) -> XMLEncoder.NodeEncoding } diff --git a/Sources/XMLCoder/Encoder/XMLEncoder.swift b/Sources/XMLCoder/Encoder/XMLEncoder.swift index 23efd3d0..48ca427e 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 @@ -233,8 +233,8 @@ open class XMLEncoder { @available(*, deprecated, renamed: "NodeEncodingStrategy") public typealias NodeEncodingStrategies = NodeEncodingStrategy - public typealias XMLNodeEncoderClosure = (CodingKey) -> NodeEncoding? - public typealias XMLEncodingClosure = (Encodable.Type, Encoder) -> XMLNodeEncoderClosure + public typealias XMLNodeEncoderClosure = @Sendable (CodingKey) -> NodeEncoding? + public typealias XMLEncodingClosure = @Sendable (Encodable.Type, Encoder) -> XMLNodeEncoderClosure /// Set of strategies to use for encoding of nodes. public enum NodeEncodingStrategy { From 80efd7c1ac472aa8f7527315d92d8ca260c47ac9 Mon Sep 17 00:00:00 2001 From: leogdion Date: Thu, 17 Jul 2025 10:43:55 -0400 Subject: [PATCH 2/7] fixing Swift 5.6 issue --- Sources/XMLCoder/Encoder/XMLEncoder.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/XMLCoder/Encoder/XMLEncoder.swift b/Sources/XMLCoder/Encoder/XMLEncoder.swift index 48ca427e..98719d0f 100644 --- a/Sources/XMLCoder/Encoder/XMLEncoder.swift +++ b/Sources/XMLCoder/Encoder/XMLEncoder.swift @@ -262,7 +262,9 @@ open class XMLEncoder { guard let dynamicType = codableType as? DynamicNodeEncoding.Type else { return { _ in nil } } - return dynamicType.nodeEncoding(for:) + return { (@Sendable key: CodingKey) in + dynamicType.nodeEncoding(for: key) + } } } From 4c5746da9a6374fc69949748c18cf97dc0011160 Mon Sep 17 00:00:00 2001 From: leogdion Date: Thu, 17 Jul 2025 10:50:18 -0400 Subject: [PATCH 3/7] fix for older Swift versions and newer Swift versions --- Sources/XMLCoder/Encoder/XMLEncoder.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/XMLCoder/Encoder/XMLEncoder.swift b/Sources/XMLCoder/Encoder/XMLEncoder.swift index 98719d0f..f3f60e43 100644 --- a/Sources/XMLCoder/Encoder/XMLEncoder.swift +++ b/Sources/XMLCoder/Encoder/XMLEncoder.swift @@ -262,9 +262,13 @@ open class XMLEncoder { guard let dynamicType = codableType as? DynamicNodeEncoding.Type else { return { _ in nil } } + #if swift(>=6.1) + return dynamicType.nodeEncoding(for:) + #else return { (@Sendable key: CodingKey) in dynamicType.nodeEncoding(for: key) } + #endif } } From 5ec940f0af161f07deb025fd5f85c0a5d0cb2a9e Mon Sep 17 00:00:00 2001 From: leogdion Date: Thu, 17 Jul 2025 10:53:06 -0400 Subject: [PATCH 4/7] white-space fix [skip ci] --- Sources/XMLCoder/Encoder/XMLEncoder.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/XMLCoder/Encoder/XMLEncoder.swift b/Sources/XMLCoder/Encoder/XMLEncoder.swift index f3f60e43..7278e1cd 100644 --- a/Sources/XMLCoder/Encoder/XMLEncoder.swift +++ b/Sources/XMLCoder/Encoder/XMLEncoder.swift @@ -263,11 +263,11 @@ open class XMLEncoder { return { _ in nil } } #if swift(>=6.1) - return dynamicType.nodeEncoding(for:) + return dynamicType.nodeEncoding(for:) #else - return { (@Sendable key: CodingKey) in - dynamicType.nodeEncoding(for: key) - } + return { (@Sendable key: CodingKey) in + dynamicType.nodeEncoding(for: key) + } #endif } } From 7ba3ef6fdf5a3c099cbf61ff69b9718ee9b19044 Mon Sep 17 00:00:00 2001 From: leogdion Date: Thu, 17 Jul 2025 10:57:07 -0400 Subject: [PATCH 5/7] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 39274260..c1e69193 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ name: CI # events but only for the main branch on: push: - branches: [main] + branches: "*" pull_request: branches: "*" From 24bb33bce408bb8380232a821e65f00ff06c4708 Mon Sep 17 00:00:00 2001 From: leogdion Date: Thu, 17 Jul 2025 14:15:04 -0400 Subject: [PATCH 6/7] git subrepo pull (merge) Packages/XMLCoder subrepo: subdir: "Packages/XMLCoder" merged: "2b2a748" upstream: origin: "git@github.com:brightdigit/XMLCoder.git" branch: "syndikit-swift-6.2" commit: "7ba3ef6" git-subrepo: version: "0.4.9" origin: "https://github.com/Homebrew/brew" commit: "23c491e5bc" --- 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 7278e1cd..3444c733 100644 --- a/Sources/XMLCoder/Encoder/XMLEncoder.swift +++ b/Sources/XMLCoder/Encoder/XMLEncoder.swift @@ -262,7 +262,7 @@ open class XMLEncoder { guard let dynamicType = codableType as? DynamicNodeEncoding.Type else { return { _ in nil } } - #if swift(>=6.1) + #if compiler(>=6.1) return dynamicType.nodeEncoding(for:) #else return { (@Sendable key: CodingKey) in From 2fea91d84053e96fcb2e4ee2e66e27a2fb845b3e Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Thu, 17 Jul 2025 15:17:14 -0400 Subject: [PATCH 7/7] undo change for tests --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c1e69193..39274260 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ name: CI # events but only for the main branch on: push: - branches: "*" + branches: [main] pull_request: branches: "*"