SwiftPM's command plugin can build any target with the PackageManager API.
However, when the executable target has an async main function, and the minimum deployment target is macOS 26, the latest main snapshot toolchain generates a broken executable that crashes on launch.
Executable Target:
@main
struct Foo {
static func main() async {}
}Command Plugin:
@main
struct BenchmarkCommandPlugin: CommandPlugin {
func performCommand(context: PluginContext, arguments: [String]) throws {
let result = try self.packageManager.build(.product("Foo"), parameters: .init(configuration: .release))
guard result.succeeded else {
preconditionFailure("build failure")
}
}
}swift package build
.build/release/Foo # crash$ sw_vers
ProductName: macOS
ProductVersion: 26.2
BuildVersion: 25C56$ swift --version
Apple Swift version 6.3-dev (LLVM d402ab9729f318e, Swift 2de856568572fc0)
Target: arm64-apple-macosx26.0
Build config: +assertions