I have a library that contains code that is brand specific. When I build a buildtool plugin it should accept a parameter during the build to produce the correct source files for that brand in the build output directory. I can do this by adding the parameter for the brand to the arguments of the buildtool plugin.
import PackagePlugin
import Foundation
@main
struct BrandPicker: BuildToolPlugin {
func createBuildCommands(
context: PackagePlugin.PluginContext,
target: PackagePlugin.Target
) async throws -> [PackagePlugin.Command] {
// We only care about the source module targets
guard let target = target as? SourceModuleTarget else {
return []
}
let input = target.directory.appending("Common.swift")
let output = context.pluginWorkDirectory.appending(["CommonOutput.swift"])
return [
.buildCommand(
displayName: "Add branded files",
executable: try context.tool(named: "<#main#>").path,
arguments: [output.string] + ["<#brand#>"],
inputFiles: [input],
outputFiles: [output]
)
]
}
}
I seam to only be able to harcode the <#brand#>
parameter into the build process as during the build arguments or environment variables I add to the scheme that builds this target get ignored. My maybe naive mind was expecting things I put into the scheme to build the library to get passed to the ProcessInfo().arguments
, but they do not apparently. I guess this is the intended way of working? Or could this be a feature request?