Contents

Target

The basic building block of a Swift package.

Declaration

final class Target

Overview

Each target contains a set of source files that Swift Package Manager compiles into a module or test suite. You can vend targets to other packages by defining products that include the targets.

A target may depend on other targets within the same package and on products vended by the package’s dependencies.

Test Libraries Targets

Built-in testing libraries, such as Swift Testing and XCTest, are only available for use in certain runtime contexts. While you can use these within Swift libraries intended for testing, take care so that any such libraries only terminate in test targets, as targets that use Swift Testing or XCTest should never be distributed to end users. Including testing libraries as a dependency to an executable target, as either a direct or transitive dependency, can cause clients to encounter linking issues.

Topics

Naming the Target

Configuring File Locations

Creating a Binary Target

Creating a System Library Target

Creating an Executable Target

Creating a Regular Target

Creating a Test Target

Creating a Plugin Target

Declaring a Dependency Target

Configuring the Target

Describing the Target Type

See Also

Configuring Targets