From 44ca1134fad48b78448e968633e9db0b872b9476 Mon Sep 17 00:00:00 2001 From: Maksym Bilan Date: Wed, 26 Aug 2026 11:05:06 +0200 Subject: [PATCH] Fix watchOS build failure on Xcode 27 Xcode 27 raises the minimum watchOS deployment target from 4.0 to 9.0, so the package's declared `.watchOS(.v6)` floor is clamped up to 9.0. That collides exactly with the `obsoleted: 9.0` annotation on the private `split(by:)` back-deployment fallback: error: 'split(by:)' is unavailable in watchOS: This method is not recommended on watchOS 9.0+ Sitting in the `else` of `if #available(..., watchOS 9.0, *)` does not help: an `#available` else branch does not lower the availability context, so the call is still checked against the deployment target and rejected. Drop the `@available` attributes from the helper and rename it to `legacySplit(by:)`. They were decorative on a fileprivate method nothing outside the file could call, but they broke the build. This also removes the need for the `#if os(visionOS)` special case added in 1c45c73, which worked around the same root cause. iOS and macOS are one OS release from hitting this too (clamped to 15.0/12.0 against `obsoleted:` 16.0/13.0), so removing the annotations avoids a repeat on the next toolchain. Deployment targets in Package.swift are unchanged; this is not a breaking change for consumers. Verified: clean builds on watchOS, iOS, tvOS, visionOS and macOS under Xcode 27.0 beta (27A5252f); still builds under Xcode 26.6; all 7 tests pass. Co-Authored-By: Claude Opus 5 (1M context) --- Sources/EventSource/EventParser.swift | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Sources/EventSource/EventParser.swift b/Sources/EventSource/EventParser.swift index 27770d9..729b1c4 100644 --- a/Sources/EventSource/EventParser.swift +++ b/Sources/EventSource/EventParser.swift @@ -82,15 +82,11 @@ struct ServerEventParser: EventParser { } private func splitData(_ data: Data, separator: [UInt8]) -> [Data] { - #if os(visionOS) - return data.split(separator: separator) - #else if #available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) { return data.split(separator: separator) } else { - return data.split(by: separator) + return data.legacySplit(by: separator) } - #endif } private func findLastSeparator(in data: Data, separators: [[UInt8]]) -> ([UInt8]?, Range?) { @@ -125,12 +121,10 @@ struct ServerEventParser: EventParser { } fileprivate extension Data { - @available(macOS, deprecated: 13.0, obsoleted: 13.0, message: "This method is not recommended on macOS 13.0+") - @available(iOS, deprecated: 16.0, obsoleted: 16.0, message: "This method is not recommended on iOS 16.0+") - @available(watchOS, deprecated: 9.0, obsoleted: 9.0, message: "This method is not recommended on watchOS 9.0+") - @available(tvOS, deprecated: 16.0, obsoleted: 16.0, message: "This method is not recommended on tvOS 16.0+") - @available(visionOS, unavailable, message: "Use split(separator:) instead") - func split(by separator: [UInt8]) -> [Data] { + // Fallback for `split(separator:)`, which needs macOS 13/iOS 16/watchOS 9/tvOS 16. + // No `@available` here on purpose: `obsoleted:` becomes a hard error once a toolchain + // raises the deployment floor to that version, even inside an `#available` else branch. + func legacySplit(by separator: [UInt8]) -> [Data] { var chunks: [Data] = [] var pos = startIndex // Find next occurrence of separator after current position