<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "PackageDescription",
  "identifier" : "/documentation/PackageDescription/Target",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "PackageDescription"
    ],
    "preciseIdentifier" : "s:18PackageDescription6TargetC"
  },
  "title" : "Target"
}
-->

# Target

The basic building block of a Swift package.

```
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.

## Topics

### Naming the Target

[`name`](/documentation/PackageDescription/Target/name)

The name of the target.

### Configuring File Locations

[`path`](/documentation/PackageDescription/Target/path)

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

[`exclude`](/documentation/PackageDescription/Target/exclude)

The paths to source and resource files that you don’t want to include in the target.

[`sources`](/documentation/PackageDescription/Target/sources)

The source files in this target.

[`resources`](/documentation/PackageDescription/Target/resources)

The explicit list of resource files in the target.

[`Resource`](/documentation/PackageDescription/Resource)

A resource to bundle with the Swift package.

[`publicHeadersPath`](/documentation/PackageDescription/Target/publicHeadersPath)

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

### Creating a Binary Target

[`binaryTarget(name:path:)`](/documentation/PackageDescription/Target/binaryTarget(name:path:))

Creates a binary target that references an artifact on disk.

[`binaryTarget(name:url:checksum:)`](/documentation/PackageDescription/Target/binaryTarget(name:url:checksum:))

Creates a binary target that references a remote artifact.

[`url`](/documentation/PackageDescription/Target/url)

The URL of a binary target.

[`checksum`](/documentation/PackageDescription/Target/checksum)

The checksum for the archive file that contains the referenced binary
artifact.

### Creating a System Library Target

[`systemLibrary(name:path:pkgConfig:providers:)`](/documentation/PackageDescription/Target/systemLibrary(name:path:pkgConfig:providers:))

Creates a system library target.

[`pkgConfig`](/documentation/PackageDescription/Target/pkgConfig)

The name of the package configuration file, without extension, for the system library target.

[`providers`](/documentation/PackageDescription/Target/providers)

The providers array for a system library target.

### Creating an Executable Target

[`executableTarget(name:dependencies:path:exclude:sources:resources:publicHeadersPath:packageAccess:cSettings:cxxSettings:swiftSettings:linkerSettings:plugins:)`](/documentation/PackageDescription/Target/executableTarget(name:dependencies:path:exclude:sources:resources:publicHeadersPath:packageAccess:cSettings:cxxSettings:swiftSettings:linkerSettings:plugins:))

Creates an executable target.

[`executableTarget(name:dependencies:path:exclude:sources:resources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:plugins:)`](/documentation/PackageDescription/Target/executableTarget(name:dependencies:path:exclude:sources:resources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:plugins:))

Creates an executable target.

[`executableTarget(name:dependencies:path:exclude:sources:resources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:)`](/documentation/PackageDescription/Target/executableTarget(name:dependencies:path:exclude:sources:resources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:))

Creates an executable target.

### Creating a Regular Target

[`target(name:dependencies:path:exclude:sources:resources:publicHeadersPath:packageAccess:cSettings:cxxSettings:swiftSettings:linkerSettings:plugins:)`](/documentation/PackageDescription/Target/target(name:dependencies:path:exclude:sources:resources:publicHeadersPath:packageAccess:cSettings:cxxSettings:swiftSettings:linkerSettings:plugins:))

Creates a regular target.

[`target(name:dependencies:path:exclude:sources:resources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:plugins:)`](/documentation/PackageDescription/Target/target(name:dependencies:path:exclude:sources:resources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:plugins:))

Creates a regular target.

[`target(name:dependencies:path:exclude:sources:resources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:)`](/documentation/PackageDescription/Target/target(name:dependencies:path:exclude:sources:resources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:))

Creates a regular target.

[`target(name:dependencies:path:exclude:sources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:)`](/documentation/PackageDescription/Target/target(name:dependencies:path:exclude:sources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:))

Creates a library or executable target.

[`target(name:dependencies:path:exclude:sources:publicHeadersPath:)`](/documentation/PackageDescription/Target/target(name:dependencies:path:exclude:sources:publicHeadersPath:))

Creates a library or executable target.

### Creating a Test Target

[`testTarget(name:dependencies:path:exclude:sources:resources:packageAccess:cSettings:cxxSettings:swiftSettings:linkerSettings:plugins:)`](/documentation/PackageDescription/Target/testTarget(name:dependencies:path:exclude:sources:resources:packageAccess:cSettings:cxxSettings:swiftSettings:linkerSettings:plugins:))

Creates a test target.

[`testTarget(name:dependencies:path:exclude:sources:resources:cSettings:cxxSettings:swiftSettings:linkerSettings:plugins:)`](/documentation/PackageDescription/Target/testTarget(name:dependencies:path:exclude:sources:resources:cSettings:cxxSettings:swiftSettings:linkerSettings:plugins:))

Creates a test target.

[`testTarget(name:dependencies:path:exclude:sources:resources:cSettings:cxxSettings:swiftSettings:linkerSettings:)`](/documentation/PackageDescription/Target/testTarget(name:dependencies:path:exclude:sources:resources:cSettings:cxxSettings:swiftSettings:linkerSettings:))

Creates a test target.

[`testTarget(name:dependencies:path:exclude:sources:cSettings:cxxSettings:swiftSettings:linkerSettings:)`](/documentation/PackageDescription/Target/testTarget(name:dependencies:path:exclude:sources:cSettings:cxxSettings:swiftSettings:linkerSettings:))

Creates a test target.

[`testTarget(name:dependencies:path:exclude:sources:)`](/documentation/PackageDescription/Target/testTarget(name:dependencies:path:exclude:sources:))

Creates a test target.

### Creating a Plugin Target

[`plugin(name:capability:dependencies:path:exclude:sources:packageAccess:)`](/documentation/PackageDescription/Target/plugin(name:capability:dependencies:path:exclude:sources:packageAccess:))

Defines a new package plug-in target.

[`pluginCapability`](/documentation/PackageDescription/Target/pluginCapability-swift.property)

The capability provided by a package plug-in target.

[`Target.PluginCapability`](/documentation/PackageDescription/Target/PluginCapability-swift.enum)

The different types of capability that a plug-in can provide.

[`PluginCommandIntent`](/documentation/PackageDescription/PluginCommandIntent)

The intended use case of the command plug-in.

[`PluginPermission`](/documentation/PackageDescription/PluginPermission)

The type of permission a plug-in requires.

[`plugin(name:capability:dependencies:path:exclude:sources:)`](/documentation/PackageDescription/Target/plugin(name:capability:dependencies:path:exclude:sources:))

Defines a new package plugin target.

### Declaring a Dependency Target

[`dependencies`](/documentation/PackageDescription/Target/dependencies)

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

[`Target.Dependency`](/documentation/PackageDescription/Target/Dependency)

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

[`TargetDependencyCondition`](/documentation/PackageDescription/TargetDependencyCondition)

A condition that limits the application of a target’s dependency.

### Configuring the Target

[`cSettings`](/documentation/PackageDescription/Target/cSettings)

The target’s C build settings.

[`cxxSettings`](/documentation/PackageDescription/Target/cxxSettings)

The target’s C++ build settings.

[`swiftSettings`](/documentation/PackageDescription/Target/swiftSettings)

The target’s Swift build settings.

[`linkerSettings`](/documentation/PackageDescription/Target/linkerSettings)

The target’s linker settings.

[`plugins`](/documentation/PackageDescription/Target/plugins)

The uses of package plug-ins by the target.

[`BuildConfiguration`](/documentation/PackageDescription/BuildConfiguration)

The build configuration, such as debug or release.

[`BuildSettingCondition`](/documentation/PackageDescription/BuildSettingCondition)

A condition that limits the application of a build setting.

[`CSetting`](/documentation/PackageDescription/CSetting)

A C language build setting.

[`CXXSetting`](/documentation/PackageDescription/CXXSetting)

A CXX-language build setting.

[`SwiftSetting`](/documentation/PackageDescription/SwiftSetting)

A Swift language build setting.

[`LinkerSetting`](/documentation/PackageDescription/LinkerSetting)

A linker build setting.

[`Target.PluginUsage`](/documentation/PackageDescription/Target/PluginUsage)

A plug-in used in a target.

[`packageAccess`](/documentation/PackageDescription/Target/packageAccess)

If true, access to package declarations from other targets in the package is allowed.

### Describing the Target Type

[`isTest`](/documentation/PackageDescription/Target/isTest)

A Boolean value that indicates whether this is a test target.

[`type`](/documentation/PackageDescription/Target/type)

The type of the target.

[`Target.TargetType`](/documentation/PackageDescription/Target/TargetType)

The different types of a target.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)