Executable Plugin
Allows you to reuse executable files among multiple projects.
Creating a plugin
In the Plugin manifest, you must define the names of the executable files ExecutablePlugin; based on these, the executable files specified in Package.swift will be compiled.
Plugin.swift
import ProjectDescription
let plugin = Plugin(
name: "GekoPlugin",
executables: [
ExecutablePlugin(name: "ExampleGekoExecutable")
]
)Package.swift
// swift-tools-version:6.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "RemotePlugin",
platforms: [.macOS(.v14)],
products: [
.executable(
name: "ExampleGekoExecutable",
targets: ["ExampleTarget"]
),
],
dependencies: [],
targets: [
.executableTarget(
name: "ExampleTarget",
dependencies: []
),
]
)[Link to the source code of the plugin from the example above]https://github.com/geko-tech/geko-plugins/tree/main/ExecutablePluginExample).
Usage
Using in the terminal
geko <plugin-name> [<executable-name>]If there is only one executable file, then it is enough to specify only the name of the plugin:
geko GekoPlugin --arg1 arg1If there are several executable files, you must specify the name of the plugin and the name of the executable file:
geko GekoPlugin ExampleGekoExecutable --arg1 arg1You can also get the absolute path to the executable file, which may be useful if for some reason you need to call the executable file directly, for example, to get clean standard output without Geko logs:
geko plugin path GekoPlugin ExampleGekoExecutableUsage in preFetchScripts, preGenerateScripts, and postGenerateScripts
let config = Config(
preFetchScripts: [
// If the plugin has one executable file
.plugin(name: "GekoPlugin", args: ["--version"]),
// If there are multiple executable files in a plugin
.plugin(name: "GekoPlugin", executable: "ExampleGekoExecutable", args: ["--version"]),
]
)