---
title: "Command.prebuildCommand(displayName:executable:arguments:environment:outputFilesDirectory:)"
framework: swift-package-manager
role: symbol
role_heading: Case
path: "swift-package-manager/documentation/packageplugin/command/prebuildcommand(displayname:executable:arguments:environment:outputfilesdirectory:)-swift.enum.case"
---

# Command.prebuildCommand(displayName:executable:arguments:environment:outputFilesDirectory:)

Returns a command that runs unconditionally before every build.

## Declaration

```swift
case prebuildCommand(displayName: String?, executable: URL, arguments: [String], environment: [String : String] = [:], outputFilesDirectory: URL)
```

## Parameters

- `displayName`: An optional string to show in build logs and other status areas.
- `executable`: The absolute path to the executable to invoke.
- `arguments`: The command-line arguments for the executable.
- `environment`: Any environment variable assignments visible to the executable.
- `outputFilesDirectory`: A directory into which the command writes its output files. The package manager compiles any files there recognizable by their extension as source files (for example, .swift) into the target for which this command was generated as if in its source directory; other files are treated as resources as if explicitly listed in Package.swift using .process(...).

## Discussion

Discussion Prebuild commands can have a significant performance impact and should only be used when there would be no way to know the list of output file paths without first reading the contents of one or more input files. Typically there is no way to determine this list without first running the command, so instead of encoding that list, the caller supplies an outputFilesDirectory parameter, and all files in that directory after the command runs are treated as the output files of the plugin.

## See Also

### Types of Build Commands

- [Command.buildCommand(displayName:executable:arguments:environment:inputFiles:outputFiles:)](swift-package-manager/documentation/packageplugin/command/buildcommand(displayname:executable:arguments:environment:inputfiles:outputfiles:)-swift.enum.case.md)
- [buildCommand(displayName:executable:arguments:environment:inputFiles:outputFiles:)](swift-package-manager/documentation/packageplugin/command/buildcommand(displayname:executable:arguments:environment:inputfiles:outputfiles:)-swift.type.method.md)
- [prebuildCommand(displayName:executable:arguments:environment:outputFilesDirectory:)](swift-package-manager/documentation/packageplugin/command/prebuildcommand(displayname:executable:arguments:environment:outputfilesdirectory:)-swift.type.method.md)
