---
title: Plugins
framework: swift-package-manager
role: collectionGroup
path: swift-package-manager/documentation/packagemanagerdocs/plugins
---

# Plugins

Extend package manager functionality with build or command plugins.

## Overview

Overview Some of Swift Package Manager’s functionality can be extended through plugins. Write package plugins using the PackagePlugin API provided by the Swift Package Manager.  This is similar to how the package manifest is implemented — as Swift code that runs as needed in order to produce the information package manager needs. Package manager defines two extension points for plugins: Plugin Capabilities Plugins have access to a representation of the package model. Command plugins can also invoke services provided by package manager to build and test products and targets defined in the package to which the plugin is applied. Every plugin runs as a separate process from the package manager. On platforms that support sandboxing, package manager wraps the plugin in a sandbox that prevents network access and attempts to write to arbitrary locations in the file system. All plugins can write to a temporary directory. Custom command plugins that need to modify the package source code can specify this requirement. If the user approves, package manager grants write access to the package directory. Build tool plugins can’t modify the package source code. Creating Plugins When creating a plugin, represent a plugin in the package manifest as a target of the pluginTarget type. If it should be available to other packages, also include a corresponding pluginProduct target. Source code for a plugin is normally located in a directory under the Plugins directory in the package, but this can be customized. A plugin declares which extension point it implements by defining the plugin’s capability. This determines the entry point through which package manager will call it, and determines which actions the plugin can perform. References “Meet Swift Package plugins” WWDC22 session “Create Swift Package plugins” WWDC22 session

## Topics

### Enabling Plugins

- [Enable a command plugin](swift-package-manager/documentation/packagemanagerdocs/enablecommandplugin.md)
- [Enable a build plugin](swift-package-manager/documentation/packagemanagerdocs/enablebuildplugin.md)

### Writing Plugins

- [Writing a command plugin](swift-package-manager/documentation/packagemanagerdocs/writingcommandplugin.md)
- [Writing a build tool plugin](swift-package-manager/documentation/packagemanagerdocs/writingbuildtoolplugin.md)

## See Also

### Guides

- [Creating a Swift package](swift-package-manager/documentation/packagemanagerdocs/creatingswiftpackage.md)
- [Setting the Swift tools version](swift-package-manager/documentation/packagemanagerdocs/settingswifttoolsversion.md)
- [Adding dependencies to a Swift package](swift-package-manager/documentation/packagemanagerdocs/addingdependencies.md)
- [Resolving and updating dependencies](swift-package-manager/documentation/packagemanagerdocs/resolvingpackageversions.md)
- [Creating C language targets](swift-package-manager/documentation/packagemanagerdocs/creatingclanguagetargets.md)
- [Using build configurations](swift-package-manager/documentation/packagemanagerdocs/usingbuildconfigurations.md)
- [Packaging based on the version of Swift](swift-package-manager/documentation/packagemanagerdocs/swiftversionspecificpackaging.md)
- [Bundling resources with a Swift package](swift-package-manager/documentation/packagemanagerdocs/bundlingresources.md)
- [Releasing and publishing a Swift package](swift-package-manager/documentation/packagemanagerdocs/releasingpublishingapackage.md)
- [Generating Software Bill of Materials (SBOM)](swift-package-manager/documentation/packagemanagerdocs/generatingsboms.md)
- [Continuous Integration Workflows](swift-package-manager/documentation/packagemanagerdocs/continuousintegration.md)
- [Module Aliasing](swift-package-manager/documentation/packagemanagerdocs/modulealiasing.md)
- [Using a package registry](swift-package-manager/documentation/packagemanagerdocs/usingswiftpackageregistry.md)
- [Package Collections](swift-package-manager/documentation/packagemanagerdocs/packagecollections.md)
- [Using shell completion scripts](swift-package-manager/documentation/packagemanagerdocs/usingshellcompletion.md)
