Library Moduleswift-package-manager 5.10.1PackageDescription
PackageDescription
Create reusable code, organize it in a lightweight way, and share it across your projects and with other developers.
PackageDescription.mdimport PackageDescription
Module information
- Declarations
- 377
- Symbols
- 419
Swift packages are reusable components of Swift, Objective-C, Objective-C++, C, or C++ code that developers can use in their projects. They bundle source files, binaries, and resources in a way that’s easy to use in your app’s project.
Each Swift package requires a Package.swift
file in the main directory of the package — referred to as the package manifest. When you create a Swift package, you use the PackageDescription library in the package manifest to list dependencies, configure localized resources, and set other configuration options.
For example, the package manifest from the SlothCreator: Building DocC Documentation in Xcode sample project below defines the SlothCreator package, with the SlothCreator library in it. It specifies the deployment targets, and that its resources are in the Resources
folder.
import PackageDescription
let package = Package(
name: "SlothCreator",
platforms: [
.macOS(.v11),
.iOS(.v14),
.watchOS(.v7),
.tvOS(.v13)
],
products: [
.library(
name: "SlothCreator",
targets: ["SlothCreator"]
)
],
targets: [
.target(
name: "SlothCreator",
resources: [
.process("Resources/")
]
)
]
)
The package manifest also allows you to define executable products, as well as plugins that Swift Package Manager can use to build other products in the manifest.
For more information about adding a package dependency to your app project and creating Swift packages with Xcode, see Adding Package Dependencies to Your App, Creating a Standalone Swift Package with Xcode, and Swift Packages.
Support for Swift packages in Xcode builds on the open-source Swift Package Manager project. To learn more about the Swift Package Manager, visit Swift.org and the Swift Package Manager repository on GitHub.
Creating a Package
class Package
The configuration of a Swift package.
struct Context
The context information for a Swift package.
Uncategorized
Types
enum PluginNetworkPermissionScope
The scope of a network permission.
Other modules
Basics
Build
CompilerPluginSupport
DriverSupport
LLBuildManifest
PackageCollections
PackageCollectionsModel
PackageCollectionsSigning
PackageFingerprint
PackageGraph
PackageLoading
PackageMetadata
PackageModel
PackagePlugin
PackageRegistry
PackageSigning
SPMBuildCore
SPMLLBuild
SPMSQLite3system
SourceControl
Workspace
XCBuildSupport