A target, the basic building block of a Swift package.


final class Target


Each target contains a set of source files that are compiled 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.


Naming the Target

var name: String

The name of the target.

Configuring Source File Locations

var path: String?

The path of the target, relative to the package root.

var exclude: [String]

The paths you want to exclude from source inference.

var sources: [String]?

The source files in this target.

var publicHeadersPath: String?

The path to the directory containing public headers of a C-family target.

Creating a System Target

let pkgConfig: String?

The pkgconfig name to use for a system library target.

let providers: [SystemPackageProvider]?

The providers array for a system library target.

Declaring a Target Dependency

var dependencies: [Target.Dependency]

The target’s dependencies on other entities inside or outside the package.

enum Target.Dependency

The different types of a target’s dependency on another entity.

Configuring the Target

struct BuildConfiguration

The build configuration such as debug or release..

struct BuildSettingCondition

A condition that limits the application of a build setting.

struct CSetting

A C-language build setting.

struct CXXSetting

A CXX-language build setting.

struct SwiftSetting

A Swift language build setting.

struct LinkerSetting

A linker build setting.

Describing the Target Type

var isTest: Bool

A boolean value that indicates if this is a test target.

let type: Target.TargetType

The type of the target.

enum Target.TargetType

The different types of a target.

Encoding and Decoding

func encode(to: Encoder)

Encodes this value into the given encoder.


Conforms To

See Also

Configuring Targets

var targets: [Target]

The list of targets.