From a1cea406443584f8c4320c7bbdd33bfdadcfb41f Mon Sep 17 00:00:00 2001 From: kPherox Date: Thu, 12 Mar 2026 03:27:05 +0900 Subject: [PATCH 1/3] Fix unknown target type in Swift 5.8 refs apple/swift-argument-parser#803 `swift package resolve` in Swift 5.8.x: ``` Computing version for https://github.com/apple/swift-argument-parser.git error: Invalid manifest (compiled with: ["/usr/bin/swiftc", "-vfsoverlay", "/tmp/TemporaryDirectory.HCuAi3/vfs.yaml", "-L", "/usr/lib/swift/pm/ManifestAPI", "-lPackageDescription", "-Xlinker", "-rpath", "-Xlinker", "/usr/lib/swift/pm/ManifestAPI", "-swift-version", "5", "-I", "/usr/lib/swift/pm/ManifestAPI", "-package-description-version", "5.8.0", "/Package@swift-5.8.swift", "-Xfrontend", "-disable-implicit-concurrency-module-import", "-Xfrontend", "-disable-implicit-string-processing-module-import", "-o", "/tmp/TemporaryDirectory.RLkqp3/swift-argument-parser-manifest"]) /Package@swift-5.8.swift:149:9: error: type 'Target.TargetType' has no member 'macro' case .macro, .plugin, .system, .binary: ~^~~~~ in https://github.com/apple/swift-argument-parser.git ``` --- Package@swift-5.8.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Package@swift-5.8.swift b/Package@swift-5.8.swift index fb860aff1..9b4d0aa6c 100644 --- a/Package@swift-5.8.swift +++ b/Package@swift-5.8.swift @@ -146,9 +146,7 @@ for target in package.targets { // https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md settings.append(.enableUpcomingFeature("MemberImportVisibility")) target.swiftSettings = settings - case .macro, .plugin, .system, .binary: + default: break // not applicable - @unknown default: - break // we don't know what to do here, do nothing } } From 35912b37bf280c019db67f9a18b96ab73d883f71 Mon Sep 17 00:00:00 2001 From: kPherox Date: Thu, 12 Mar 2026 17:56:22 +0900 Subject: [PATCH 2/3] Fix to remove access level modifier on imports for Swift 5 fix apple/swift-argument-parser#870 refs apple/swift-argument-parser#804 If you want without compiler conditional import, enable `InternalImportsByDefault` upcoming feature and remove `internal` from imports. --- Sources/ArgumentParser/Utilities/Mutex.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/ArgumentParser/Utilities/Mutex.swift b/Sources/ArgumentParser/Utilities/Mutex.swift index 129d0433c..6efb2a55c 100644 --- a/Sources/ArgumentParser/Utilities/Mutex.swift +++ b/Sources/ArgumentParser/Utilities/Mutex.swift @@ -10,10 +10,17 @@ //===----------------------------------------------------------------------===// #if canImport(os) +#if compiler(>=6.0) internal import os #if canImport(C.os.lock) internal import C.os.lock #endif +#else +import os +#if canImport(C.os.lock) +import C.os.lock +#endif +#endif #elseif canImport(Bionic) @preconcurrency import Bionic #elseif canImport(Glibc) From cec9c2f6098d9c5c0b6cf9596ca373fae8cfb766 Mon Sep 17 00:00:00 2001 From: kPherox Date: Thu, 12 Mar 2026 18:04:44 +0900 Subject: [PATCH 3/3] Fix unsupported conditional attributes in Swift 5.7 refs apple/swift-argument-parser#794 --- .../Parsable Properties/CompletionKind.swift | 15 ++++++++++----- .../ArgumentParser/Parsing/CommandParser.swift | 12 ++++++++---- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Sources/ArgumentParser/Parsable Properties/CompletionKind.swift b/Sources/ArgumentParser/Parsable Properties/CompletionKind.swift index 97573656c..a7a069d77 100644 --- a/Sources/ArgumentParser/Parsable Properties/CompletionKind.swift +++ b/Sources/ArgumentParser/Parsable Properties/CompletionKind.swift @@ -43,8 +43,10 @@ public struct CompletionKind { case custom(@Sendable ([String], Int, String) -> [String]) #if !canImport(Dispatch) @available(*, unavailable, message: "DispatchSemaphore is unavailable") - #endif case customAsync(@Sendable ([String], Int, String) async -> [String]) + #else + case customAsync(@Sendable ([String], Int, String) async -> [String]) + #endif case customDeprecated(@Sendable ([String]) -> [String]) } @@ -186,17 +188,20 @@ public struct CompletionKind { /// except that the closure is asynchronous. #if !canImport(Dispatch) @available(*, unavailable, message: "DispatchSemaphore is unavailable") - #endif @available(macOS 10.15, macCatalyst 13, iOS 13, tvOS 13, watchOS 6, *) public static func custom( _ completion: @Sendable @escaping ([String], Int, String) async -> [String] ) -> CompletionKind { - #if !canImport(Dispatch) fatalError("DispatchSemaphore is unavailable") - #else + } + #else + @available(macOS 10.15, macCatalyst 13, iOS 13, tvOS 13, watchOS 6, *) + public static func custom( + _ completion: @Sendable @escaping ([String], Int, String) async -> [String] + ) -> CompletionKind { CompletionKind(kind: .customAsync(completion)) - #endif } + #endif /// Deprecated; only kept for backwards compatibility. /// diff --git a/Sources/ArgumentParser/Parsing/CommandParser.swift b/Sources/ArgumentParser/Parsing/CommandParser.swift index b3296d675..81ad49441 100644 --- a/Sources/ArgumentParser/Parsing/CommandParser.swift +++ b/Sources/ArgumentParser/Parsing/CommandParser.swift @@ -531,15 +531,19 @@ private func parseCustomCompletionArguments( #if !canImport(Dispatch) @available(*, unavailable, message: "DispatchSemaphore is unavailable") -#endif @available(macOS 10.15, macCatalyst 13, iOS 13, tvOS 13, watchOS 6, *) private func asyncCustomCompletions( from args: [String], complete: @escaping @Sendable ([String], Int, String) async -> [String] ) throws -> [String] { - #if !canImport(Dispatch) throw ParserError.invalidState - #else +} +#else +@available(macOS 10.15, macCatalyst 13, iOS 13, tvOS 13, watchOS 6, *) +private func asyncCustomCompletions( + from args: [String], + complete: @escaping @Sendable ([String], Int, String) async -> [String] +) throws -> [String] { let (args, completingArgumentIndex, completingPrefix) = try parseCustomCompletionArguments(from: args) @@ -557,8 +561,8 @@ private func asyncCustomCompletions( semaphore.wait() return completionsBox.withLock { $0 } - #endif } +#endif // MARK: Building Command Stacks