Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ DerivedData/

# SwiftLint Remote Config Cache
.swiftlint/RemoteConfigCache
.claude
MEGAREADME.md
15 changes: 15 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 24 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:5.11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

Swift 5.11 release date tools version availability

💡 Result:

  • Swift 5.11 “release date” (stable): There was no general-availability Swift 5.11 release. The last Swift 5.x major release was Swift 5.10 (March 5, 2024), and the next major release was Swift 6 (September 17, 2024). [1][2]
  • Where “Swift 5.11” existed: “5.11” showed up as a development-snapshot/toolchain identifier during the period after Swift 5.10 and before Swift 6 (e.g., Swift Forums discussions referencing “swift-DEVELOPMENT-SNAPSHOT … (which should map to 5.11)”). [3]
  • Xcode / toolchain availability: Apple’s Xcode line moved from Swift 5.10-era toolchains to Swift 6.0 in Xcode 16 (i.e., not Swift 5.11). [2][4]
  • SwiftPM swift-tools-version: 5.11: If you’re asking about Swift Package Manager tools version 5.11, it’s not tied to a stable “Swift 5.11” compiler release, and using newer tools versions inside Xcode can be confusing because Xcode uses its own embedded SwiftPM, which may not match an installed custom toolchain. [3]

Sources:
[1] Swift.org — Swift 5.10 Released (Mar 5, 2024) (swift.org)
[2] Swift.org — Announcing Swift 6 (Sep 17, 2024) (swift.org)
[3] Swift Forums — discussion of 5.10/“5.11” development snapshots & Xcode SwiftPM behavior (Feb 2024) (forums.swift.org)
[4] Apple Developer — Xcode releases table showing Swift 6.0 with Xcode 16 (developer.apple.com)

Citations:


Remove swift-tools-version:5.11—this version does not exist.

Swift 5.11 was never released. Swift 5.10 (March 2024) was the final Swift 5.x release; the next version is Swift 6.0 (September 2024). "5.11" appeared only as a development snapshot identifier and is not available in any production Xcode or SwiftPM toolchain. Change to swift-tools-version:5.10 or swift-tools-version:6.0 depending on your minimum Xcode requirement.

🤖 Prompt for AI Agents
In `@Package.swift` at line 1, Replace the invalid toolchain declaration "//
swift-tools-version:5.11" in Package.swift with a supported version string —
e.g., "// swift-tools-version:5.10" or "// swift-tools-version:6.0" depending on
your minimum Xcode/toolchain requirement — so the Package.swift header uses a
real SwiftPM toolchain identifier.


import PackageDescription

Expand All @@ -9,7 +9,10 @@ let package = Package(
.library(
name: "BetterSwiftAX",
targets: ["AccessibilityControl"]
),
)
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.0"),
],
targets: [
.target(
Expand All @@ -26,5 +29,24 @@ let package = Package(
name: "AccessibilityControl",
dependencies: ["CAccessibilityControl", "WindowControl"]
),
.executableTarget(
name: "AXConstantsGenerator",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
]
),
.plugin(
name: "GenerateAXConstants",
capability: .command(
intent: .custom(
verb: "generate-ax-constants",
description: "Regenerate AX constant Swift files from HIServices headers"
),
permissions: [
.writeToPackageDirectory(reason: "Writes generated Swift source files into Sources/AccessibilityControl")
]
),
dependencies: ["AXConstantsGenerator"]
)
]
)
25 changes: 25 additions & 0 deletions Plugins/GenerateAXConstants/plugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Foundation
import PackagePlugin

@main
struct GenerateAXConstantsPlugin: CommandPlugin {
func performCommand(context: PluginContext, arguments: [String]) async throws {
let generator = try context.tool(named: "AXConstantsGenerator")

let outputDir = context.package.directory
.appending(subpath: "Sources")
.appending(subpath: "AccessibilityControl")

let process = Process()
process.executableURL = URL(fileURLWithPath: generator.path.string)
process.arguments = [outputDir.string]

try process.run()
process.waitUntilExit()

guard process.terminationStatus == 0 else {
Diagnostics.error("AXConstantsGenerator exited with code \(process.terminationStatus)")
return
}
Comment on lines +13 to +23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Generator failures are silently swallowed — capture stderr and throw on non-zero exit.

Diagnostics.error() logs but does not cause the plugin to report failure to SPM in all versions. Also, the generator's own stderr/stdout (which contains warnings and diagnostics) is not captured, so the user has no visibility into what went wrong.

🔧 Proposed fix
+        let outputPipe = Pipe()
+        let errorPipe = Pipe()
         let process = Process()
         process.executableURL = URL(fileURLWithPath: generator.path.string)
         process.arguments = [outputDir.string]
+        process.standardOutput = outputPipe
+        process.standardError = errorPipe

         try process.run()
         process.waitUntilExit()

+        let stdoutData = outputPipe.fileHandleForReading.readDataToEndOfFile()
+        let stderrData = errorPipe.fileHandleForReading.readDataToEndOfFile()
+
+        if let output = String(data: stdoutData, encoding: .utf8), !output.isEmpty {
+            print(output)
+        }
+
         guard process.terminationStatus == 0 else {
-            Diagnostics.error("AXConstantsGenerator exited with code \(process.terminationStatus)")
-            return
+            let stderr = String(data: stderrData, encoding: .utf8) ?? ""
+            throw "AXConstantsGenerator exited with code \(process.terminationStatus): \(stderr)"
         }

Note: You'll need a small String: Error conformance or use a custom error type for the throw.

🤖 Prompt for AI Agents
In `@Plugins/GenerateAXConstants/plugin.swift` around lines 13 - 23, The current
Process invocation (setting process.executableURL, process.arguments, calling
process.run()/waitUntilExit() and checking process.terminationStatus) swallows
generator stderr/stdout and only logs via Diagnostics.error; change it to set
process.standardOutput and process.standardError to Pipe, run the process, read
and decode the pipe data after waitUntilExit(), and if process.terminationStatus
!= 0 then include the decoded stderr/stdout in the Diagnostics.error message and
throw an Error (e.g., make String conform to Error or use a small custom error)
so the plugin reports failure to SPM; keep the same Process symbols
(process.executableURL, process.arguments, process.run, process.waitUntilExit,
process.terminationStatus) when implementing this.

}
}
Loading