Context.tool(named: "ModelGenerator") works when run from Xcode, fails when run from terminal

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
		}

1 Like

Issue fixed. Problem seems to have been the capital letters in the executable name.
After I've converted them all to lowercase, it worked.

1 Like