So, I'm creating a swift package command plugin.
It works perfectly when invoked from Xcode(14) when right clicking the package and select the command plugin.
However.... When running from a terminal session using the command
' swift package plugin --allow-writing-to-package-directory ModelGenerator
',
the plugin can't locate the executable and will not pass the guard statement.
What can be the cause of this?
Also, can we debug these plugins so we can figure out what's actually going on?
The code used to lookup the tool:
@main
struct ModelGeneratorCommandPlugin: CommandPlugin {
func performCommand(context: PluginContext, arguments: [String]) async throws {
guard
let executablePath = try? context.tool(named: "ModelGenerator").path
else {
print("ModelGeneratorCommandPlugin was unable to locate the 'ModelGenerator' binary")
return
}