Consider the following Package manifest file:
let package = Package(
name: "FooPackage",
products: [
.executable(
name: "FooExecutable",
targets: ["FooExecutable"]
),
.plugin(
name: "FooPlugin",
targets: ["FooPlugin"]
),
.library(
name: "FooLibrary",
targets: ["FooLibrary"]
)
],
targets: [
.executableTarget(name: "FooExecutable"),
.plugin(
name: "FooPlugin",
capability: .buildTool(),
dependencies: ["FooExecutable"]
),
.target(
name: "FooLibrary",
dependencies: [],
plugins: ["FooPlugin"]
)
]
)
And a pretty basic build tool plugin:
@main struct FooPlugin: BuildToolPlugin {
func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
let tool = try context.tool(named: "FooExecutable")
return [
.buildCommand(
displayName: "Running FooExecutable",
executable: tool.path,
arguments: []
)
]
}
}
The library target declares its dependency on the plugin, which in turn declares its dependency on an executable target, all contained within the same manifest.
When building for macOS, the executable command declared by the plugin runs successfully and the package build itself also succeeds. However if I change the destination to any other platform (i.e. iOS) , the build fails with the following error:
sandbox-exec: execvp() of '//Users/rogerio.assis/Library/Developer/Xcode/DerivedData/z-fppyndgqmxtxktbgiugzikvzesui/Build/Products/Debug-iphoneos/FooExecutable' failed: No such file or directory
It looks like the generated build script is looking for the executable inside Debug-iphoneos
however the executable is located inside the Debug
folder.
Is this expected behavior?
Thanks!
Rog