The object that defines a package product.


class Product


A package product defines an externally visible build artifact that’s available to clients of a package. The product is assembled from the build artifacts of one or more of the package’s targets. A package product can be one of two types:


Use a library product to vend library targets. This makes a target’s public APIs available to clients that integrate the Swift package.


Use an executable product to vend an executable target. Use this only if you want to make the executable available to clients.

The following example shows a package manifest for a library called “Paper” that defines multiple products:

let package = Package(
    name: "Paper",
    products: [
        .executable(name: "tool", targets: ["tool"]),
        .library(name: "Paper", targets: ["Paper"]),
        .library(name: "PaperStatic", type: .static, targets: ["Paper"]),
        .library(name: "PaperDynamic", type: .dynamic, targets: ["Paper"]),
    dependencies: [
        .package(url: "", from: "1.2.3"),
        .package(url: "http://some/other/lib", .exact("1.2.3")),
    targets: [
            name: "tool",
            dependencies: [
            name: "Paper",
            dependencies: [
                .target(name: "Utility"),
                .product(name: "AnotherExamplePackage"),


Creating a Library Product

static func library(name: String, type: Product.Library.LibraryType?, targets: [String]) -> Product

Create a library product to allow clients that declare a dependency on this package to use the package’s functionality.

class Product.Library

The library product of a Swift package.

Creating an Executable Product

static func executable(name: String, targets: [String]) -> Product

Create an executable package product that clients can run.

class Product.Executable

The executable product of a Swift package.

Naming the Product

let name: String

The name of the package product.

Encoding and Decoding

func encode(to: Encoder)

Encodes this value into the given encoder.


Conforms To

See Also

Configuring Products

var products: [Product]

The list of products that this package vends and that can be run or used by its clients.