<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "PackageDescription",
  "identifier" : "/documentation/PackageDescription/Product/library(name:type:targets:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "PackageDescription"
    ],
    "preciseIdentifier" : "s:18PackageDescription7ProductC7library4name4type7targetsACSS_AC7LibraryC0H4TypeOSgSaySSGtFZ"
  },
  "title" : "library(name:type:targets:)"
}
-->

# library(name:type:targets:)

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

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

## Parameters

`name`

The name of the library product.

`type`

The optional type of the library that’s used to determine how to
link to the library. Leave this parameter so
Swift Package Manager can choose between static or dynamic linking (recommended). If you
don’t support both linkage types, use
[`Product.Library.LibraryType.static`](/documentation/PackageDescription/Product/Library/LibraryType/static) or
[`Product.Library.LibraryType.dynamic`](/documentation/PackageDescription/Product/Library/LibraryType/dynamic) for this parameter.

`targets`

The targets that are bundled into a library product.

## Return Value

A `Product` instance.

## Discussion

A library’s product can be either statically or dynamically linked. It’s recommended
that you don’t explicitly declare the type of library, so Swift Package Manager can
choose between static or dynamic linking based on the preference of the
package’s consumer.

---

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)