Plugin doesn't have access to binary - Package Manager Extensible Build Tools (SE-0303 and SE-0305)

I' have implemented the SwiftGen example from Package Manager Extensible Build Tools with a proper zip file for the binary target according to SE-0305.

However, as soon as I use the plugin in any other swift package I receive the error: Plugin does not have access to a tool named ‘swiftgen’. Are there any access issues known for binaryTarget plugins? Please find the example implementation here: Comparing SwiftGen:stable...Kondamon:stable · SwiftGen/SwiftGen · GitHub

let package = Package(
    name: "Test",
    platforms: [.iOS("13.0")],
    products: [
        .library(
            name: "Test",
            targets: ["Test"]),
    ],
    dependencies: [
      .package(url: "https://github.com/Kondamon/SwiftGen", branch: "stable")
    ],
    targets: [
        .target(
            name: "Test",
            plugins: [
                .plugin(name: "SwiftGenPlugin", package: "SwiftGen")
            ]
        ),
        .testTarget(
            name: "TestTests",
            dependencies: ["Test"])
    ]
)
3 Likes

SwiftPM should definitely provide some better functionality to help debug this kind of issue. In this case it looks as if the problem is that the info.json in the artifact archive lists the name of the tool as "SwiftGenBinaryTarget" and not "swiftgen". So the info.plist should be changed to "swiftgen" as the key under "artifacts".

There is also an example at GitHub - abertelrud/swiftpm-buildtool-plugin-examples: Some examples of SwiftPM build tool plugins to go along with SE-0303 + SE-0325 that can be used as a template. It does have the binary inline, which is of course usually not recommended (it's better to do what you have done and host the binary separately).

3 Likes

In this case I'm guessing that even just listing the tools that it did have access to in the error message would have helped. That should be quick to address, even before anything more sophisticated.

3 Likes