Library Moduleswift-package-manager 6.0.3PackageDescription

PackageDescription

Create reusable code, organize it in a lightweight way, and share it across your projects and with other developers.

PackageDescription.md
import PackageDescription

Module information

Declarations
395
Symbols
435

Coverage

94.9 percent of the declarations in PackageDescription are fully documented4.3 percent of the declarations in PackageDescription are indirectly documented0.8 percent of the declarations in PackageDescription are completely undocumented

Declarations

0.5 percent of the declarations in PackageDescription are operators73.9 percent of the declarations in PackageDescription are initializers, type members, or enum cases13.4 percent of the declarations in PackageDescription are instance members10.1 percent of the declarations in PackageDescription are structures1.8 percent of the declarations in PackageDescription are classes0.3 percent of the declarations in PackageDescription are typealiases

Interfaces

99.7 percent of the declarations in PackageDescription are unrestricted0.3 percent of the declarations in PackageDescription are SPI (unknown)
Module stats and coverage details

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