### static func systemLibrary(name:path:pkgConfig:providers:) -> Target Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates a system library target. Use system library targets to adapt a library installed on the system to work with Swift packages. Such libraries are generally installed by system package managers (such as Homebrew and apt-get) and exposed to Swift packages by providing a `modulemap` file along with other metadata such as the library's `pkgConfig` name. ```APIDOC ## static func systemLibrary(name:path:pkgConfig:providers:) -> Target ### Description Creates a system library target. Use system library targets to adapt a library installed on the system to work with Swift packages. Such libraries are generally installed by system package managers (such as Homebrew and apt-get) and exposed to Swift packages by providing a `modulemap` file along with other metadata such as the library's `pkgConfig` name. ### Method static func ### Signature static func systemLibrary( name: String, path: String? = nil, pkgConfig: String? = nil, providers: [SystemPackageProvider]? = nil ) -> Target ### Parameters - **name** (String) - Required - The name of the target. - **path** (String?) - Optional - The custom path for the target. By default, the Swift Package Manager requires a target's sources to reside at predefined search paths; for example, `[PackageRoot]/Sources/[TargetName]`. Don't escape the package root; for example, values like `../Foo` or `/Foo` are invalid. - **pkgConfig** (String?) - Optional - The name of the `pkg-config` file for this system library. - **providers** ([SystemPackageProvider]?) - Optional - The providers for this system library. ### Returns Target - The created system library target. ``` -------------------------------- ### Initialize a Package with name, platforms, products, dependencies, and targets Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Shows the conventional nested initializer for a Package object in a Package.swift manifest. The manifest must begin with the Swift tools version comment. This example declares a package named MyLibrary with a macOS platform, a library product, a dependency on Utility, and target and test target definitions. ```swift // swift-tools-version:5.1 import PackageDescription let package = Package( name: "MyLibrary", platforms: [ .macOS(.v10_15), ], products: [ .library(name: "MyLibrary", targets: ["MyLibrary"]), ], dependencies: [ .package(url: "https://url/of/another/package/named/Utility", from: "1.0.0"), ], targets: [ .target(name: "MyLibrary", dependencies: ["Utility"]), .testTarget(name: "MyLibraryTests", dependencies: ["MyLibrary"]), ] ) ``` -------------------------------- ### Package manifest defining multiple products Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Example manifest for a library called 'Paper' that defines an executable and multiple library products with different linkage types. It also shows dependencies and targets. ```swift 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: "http://example.com.com/ExamplePackage/ExamplePackage", from: "1.2.3"), .package(url: "http://some/other/lib", .exact("1.2.3")), ], targets: [ .target( name: "tool", dependencies: [ "Paper", "ExamplePackage" ]), .target( name: "Paper", dependencies: [ "Basic", .target(name: "Utility"), .product(name: "AnotherExamplePackage"), ]) ] ) ``` -------------------------------- ### Valid Swift tools version declarations Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Lists valid examples of the required // swift-tools-version: comment that must begin a Package.swift manifest. The version declares the PackageDescription library version, minimum Swift tools version, and language compatibility version. ```swift // swift-tools-version:3.0.2 // swift-tools-version:3.1 // swift-tools-version:4.0 // swift-tools-version:5.0 // swift-tools-version:5.1 // swift-tools-version:5.2 // swift-tools-version:5.3 ``` -------------------------------- ### static func upToNextMinor(from version: Version) -> Package.Dependency.Requirement Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Returns a requirement for a version range, starting at the given minimum version and going up to the next minor version. ```APIDOC ## static func upToNextMinor(from version: Version) -> Package.Dependency.Requirement ### Description Returns a requirement for a version range, starting at the given minimum version and going up to the next minor version. ### Method static func ### Signature `static func upToNextMinor(from version: Version) -> Package.Dependency.Requirement` ### Parameters - **version** (Version) - The minimum version for the version range. ``` -------------------------------- ### static func upToNextMajor(from version: Version) -> Package.Dependency.Requirement Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Returns a requirement for a version range, starting at the given minimum version and going up to the next major version. This is the recommended version requirement. ```APIDOC ## static func upToNextMajor(from version: Version) -> Package.Dependency.Requirement ### Description Returns a requirement for a version range, starting at the given minimum version and going up to the next major version. This is the recommended version requirement. ### Method static func ### Signature `static func upToNextMajor(from version: Version) -> Package.Dependency.Requirement` ### Parameters - **version** (Version) - The minimum version for the version range. ``` -------------------------------- ### Package(name:defaultLocalization:platforms:products:dependencies:targets:swiftLanguageVersions:cLanguageStandard:cxxLanguageStandard:) Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Initializes a new Swift package configuration. Pass configuration options as parameters to provide the package's name, targets, products, dependencies, and other settings. ```APIDOC ## Package(name:defaultLocalization:platforms:products:dependencies:targets:swiftLanguageVersions:cLanguageStandard:cxxLanguageStandard:) ### Description Initializes a new Swift package configuration. Pass configuration options as parameters to provide the package's name, targets, products, dependencies, and other settings. ### Method Initializer ### Parameters - **name** (String) - Required - The name of the package. - **defaultLocalization** ([LanguageTag]?) - Optional - The default localization for the package. - **platforms** ([SupportedPlatform]?) - Optional - The supported platforms for the package. - **products** ([Product]) - Required - The products produced by the package. - **dependencies** ([Package.Dependency]) - Required - The dependencies of the package. - **targets** ([Target]) - Required - The targets of the package. - **swiftLanguageVersions** ([SwiftVersion]?) - Optional - The Swift language versions supported by the package. - **cLanguageStandard** (CLanguageStandard?) - Optional - The C language standard used by the package. - **cxxLanguageStandard** (CXXLanguageStandard?) - Optional - The C++ language standard used by the package. ### Example ```swift let package = Package( name: "MyLibrary", platforms: [ .macOS(.v10_15), ], products: [ .library(name: "MyLibrary", targets: ["MyLibrary"]), ], dependencies: [ .package(url: "https://url/of/another/package/named/Utility", from: "1.0.0"), ], targets: [ .target(name: "MyLibrary", dependencies: ["Utility"]), .testTarget(name: "MyLibraryTests", dependencies: ["MyLibrary"]), ] ) ``` ### About the Swift Tools Version A `Package.swift` manifest file must begin with the string `// swift-tools-version:` followed by a version number specifier. The Swift tools version declares the version of the `PackageDescription` library, the minimum version of the Swift tools and Swift language compatibility version to process the manifest, and the minimum version of the Swift tools that are needed to use the Swift package. ``` -------------------------------- ### Package initializer signature with all parameters Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Shows the full initializer signature for Package, including optional parameters for defaultLocalization, platforms, swiftLanguageVersions, cLanguageStandard, and cxxLanguageStandard. Note the source contains a typo: defaultLocalization uses a period instead of a comma. ```swift Package( name: String, defaultLocalization: [LanguageTag]? = nil. platforms: [SupportedPlatform]? = nil, products: [Product] = [], dependencies: [Package.Dependency] = [], targets: [Target] = [], swiftLanguageVersions: [SwiftVersion]? = nil, cLanguageStandard: CLanguageStandard? = nil, cxxLanguageStandard: CXXLanguageStandard? = nil ) ``` -------------------------------- ### static func executable(name: String, targets: [String]) -> Product Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates an executable package product that clients can run. This is used to vend an executable target to clients. ```APIDOC ## static func executable(name: String, targets: [String]) -> Product ### Description Creates an executable package product that clients can run. Use this only if you want to make the executable available to clients. ### Method static func ### Signature `static func executable(name: String, targets: [String]) -> Product` ### Parameters - **name** (String) - Required - The name of the executable product. - **targets** ([String]) - Required - The targets to bundle into an executable product. ### Returns - **Product** - The created executable product. ``` -------------------------------- ### static func executable(name: String, targets: [String]) -> Product Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates an executable package product that clients can run. This is used to vend an executable target to clients. ```APIDOC ## static func executable(name: String, targets: [String]) -> Product ### Description Creates an executable package product that clients can run. ### Method static func ### Signature `static func executable(name: String, targets: [String]) -> Product` ### Parameters - **name** (String) - Required - The name of the executable product. - **targets** ([String]) - Required - The targets to bundle into an executable product. ### Returns - **Product** - The created executable product. ``` -------------------------------- ### static func executable(name: String, targets: [String]) -> Product Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates an executable package product that clients can run. This is used to vend an executable target to clients. ```APIDOC ## static func executable(name: String, targets: [String]) -> Product ### Description Creates an executable package product that clients can run. Use this only if you want to make the executable available to clients. ### Method static func ### Signature `static func executable(name: String, targets: [String]) -> Product` ### Parameters - **name** (String) - Required - The name of the executable product. - **targets** ([String]) - Required - The targets to bundle into an executable product. ### Return Value A `Product` instance representing the executable product. ``` -------------------------------- ### static func library(name: String, type: Product.Library.LibraryType? = nil, targets: [String]) -> Product Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates a library product that allows clients to use the package's functionality. The type parameter is optional; if omitted, the Swift Package Manager chooses between static and dynamic linking based on the consumer's preference. ```APIDOC ## static func library(name: String, type: Product.Library.LibraryType? = nil, targets: [String]) -> Product ### Description Creates a library product to allow clients that declare a dependency on this package to use the package's functionality. A library's product can either be statically or dynamically linked. If possible, don't declare the type of library explicitly to let the Swift Package Manager choose between static or dynamic linking based on the preference of the package's consumer. ### Method static func ### Signature `static func library(name: String, type: Product.Library.LibraryType? = nil, targets: [String]) -> Product` ### Parameters - **name** (String) - Required - The name of the library product. - **type** (Product.Library.LibraryType?) - Optional - The optional type of the library that is used to determine how to link to the library. Leave this parameter unspecified to let the Swift Package Manager choose between static or dynamic linking (recommended). If you do not support both linkage types, use `.static` or `.dynamic` for this parameter. - **targets** ([String]) - Required - The targets that are bundled into a library product. ### Return Value - **Product** - The created library product. ### Example ```swift let package = Package( name: "Paper", products: [ .library(name: "Paper", targets: ["Paper"]), .library(name: "PaperStatic", type: .static, targets: ["Paper"]), .library(name: "PaperDynamic", type: .dynamic, targets: ["Paper"]), ], targets: [ .target(name: "Paper", dependencies: []) ] ) ``` ``` -------------------------------- ### CSetting.define(_:to:_:) Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Defines a value for a macro. If you don't specify a value, the macro's default value is 1. ```APIDOC ## CSetting.define(_:to:_:) ### Description Defines a value for a macro. If you don't specify a value, the macro's default value is 1. ### Method static func define ### Parameters - **name** (String) - The name of the macro. - **value** (String?) - The value of the macro. Optional. - **condition** (BuildSettingCondition?) - A condition that restricts the application of the build setting. Optional. ### Availability First available in PackageDescription 5.0 ``` -------------------------------- ### static func macOS(_ versionString: String) -> SupportedPlatform Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Configures the minimum deployment target version for the macOS platform using a version string. The string must be two or three dot-separated integers, such as `10.10` or `10.10.1`. Available since PackageDescription 5.0. ```APIDOC ## static func macOS(_ versionString: String) -> SupportedPlatform ### Description Configures the minimum deployment target version for the macOS platform using a version string. The version string must be a series of two or three dot-separated integers, such as `10.10` or `10.10.1`. ### Method static func ### Signature `static func macOS(_ versionString: String) -> SupportedPlatform` ### Parameters - **versionString** (String) - Required - The minimum deployment target as a string representation of two or three dot-separated integers, such as `10.10.1`. ### Availability - Since: PackageDescription 5.0 ### Returns A `SupportedPlatform` instance representing the configured platform. ``` -------------------------------- ### Resource.process(_:localization:) Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Documentation for the static method Resource.process(_:localization:) that applies platform-specific processing to a resource. ```APIDOC ## Resource.process(_:localization:) ### Description Applies a platform-specific rule to the resource at the given path. The Swift Package Manager processes resources according to the platform it builds the target for, potentially optimizing files like images. If no optimization is available, the file is copied. If the path is a directory, the rule is applied recursively. ### Method static func ### Signature static func process(_ path: String, localization: Localization? = nil) -> Resource ### Parameters - **path** (String) - Required - The path for a resource. - **localization** (Localization?) - Optional - The explicit localization type for the resource. ### Return Value Resource - A resource value representing the processed resource. ### Discussion Use this rule instead of `copy(_:)` when possible to allow automatic optimizations. ``` -------------------------------- ### LanguageTag.init(_:) Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates a language tag from its IETF string representation. This initializer is used to wrap an IETF language tag. ```APIDOC ## LanguageTag.init(_:) ### Description Creates a language tag from its IETF string representation. To learn more about the IETF worldwide standard for language tags, see RFC5646. ### Method init ### Parameters - **tag** (String) - The IETF string representation of the language tag. ``` -------------------------------- ### static func watchOS(_ versionString: String) -> SupportedPlatform Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Configures the minimum deployment target version for the watchOS platform using a version string. The string must be two or three dot-separated integers, such as `2.0` or `2.0.1`. Available since PackageDescription 5.0. ```APIDOC ## static func watchOS(_ versionString: String) -> SupportedPlatform ### Description Configures the minimum deployment target version for the watchOS platform using a version string. The version string must be a series of two or three dot-separated integers, such as `2.0` or `2.0.1`. ### Method static func ### Signature `static func watchOS(_ versionString: String) -> SupportedPlatform` ### Parameters - **versionString** (String) - Required - The minimum deployment target as a string representation of two or three dot-separated integers, such as `2.0.1`. ### Availability - Since: PackageDescription 5.0 ### Returns A `SupportedPlatform` instance representing the configured platform. ``` -------------------------------- ### static func tvOS(_ versionString: String) -> SupportedPlatform Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Configures the minimum deployment target version for the tvOS platform using a version string. The string must be two or three dot-separated integers, such as `9.0` or `9.0.1`. Available since PackageDescription 5.0. ```APIDOC ## static func tvOS(_ versionString: String) -> SupportedPlatform ### Description Configures the minimum deployment target version for the tvOS platform using a version string. The version string must be a series of two or three dot-separated integers, such as `9.0` or `9.0.1`. ### Method static func ### Signature `static func tvOS(_ versionString: String) -> SupportedPlatform` ### Parameters - **versionString** (String) - Required - The minimum deployment target as a string representation of two or three dot-separated integers, such as `9.0.1`. ### Availability - Since: PackageDescription 5.0 ### Returns A `SupportedPlatform` instance representing the configured platform. ``` -------------------------------- ### Method signatures for library and executable products Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Declarations for the static methods `library(name:type:targets:)` and `executable(name:targets:)` that create product instances. The library method allows specifying an optional linkage type, defaulting to automatic selection. ```swift /// Create a library product to allow clients that declare a dependency on this package /// to use the package's functionality. /// /// A library's product can either be statically or dynamically linked. /// If possible, don't declare the type of library explicitly to let /// the Swift Package Manager choose between static or dynamic linking based /// on the preference of the package's consumer. /// /// - Parameters: /// - name: The name of the library product. /// - type: The optional type of the library that is used to determine how to link to the library. /// Leave this parameter unspecified to let to let the Swift Package Manager choose between static or dynamic linking (recommended). /// If you do not support both linkage types, use `.static` or `.dynamic` for this parameter. /// - targets: The targets that are bundled into a library product. static func library(name: String, type: Product.Library.LibraryType? = nil, targets: [String]) -> Product /// Create an executable package product that clients can run. /// /// - Parameters: /// - name: The name of the executable product. /// - targets: The targets to bundle into an executable product. static func executable(name: String, targets: [String]) -> Product ``` -------------------------------- ### static func iOS(_ versionString: String) -> SupportedPlatform Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Configures the minimum deployment target version for the iOS platform using a version string. The string must be two or three dot-separated integers, such as `8.0` or `8.0.1`. Available since PackageDescription 5.0. ```APIDOC ## static func iOS(_ versionString: String) -> SupportedPlatform ### Description Configures the minimum deployment target version for the iOS platform using a version string. The version string must be a series of two or three dot-separated integers, such as `8.0` or `8.0.1`. ### Method static func ### Signature `static func iOS(_ versionString: String) -> SupportedPlatform` ### Parameters - **versionString** (String) - Required - The minimum deployment target as a string representation of two or three dot-separated integers, such as `8.0.1`. ### Availability - Since: PackageDescription 5.0 ### Returns A `SupportedPlatform` instance representing the configured platform. ``` -------------------------------- ### static func binaryTarget(name:path:) -> Target Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates a binary target that references an artifact on disk. A binary target provides the path to a pre-built binary artifact for the target. The Swift Package Manager only supports binary targets for Apple platforms. ```APIDOC ## static func binaryTarget(name:path:) -> Target ### Description Creates a binary target that references an artifact on disk. A binary target provides the path to a pre-built binary artifact for the target. The Swift Package Manager only supports binary targets for Apple platforms. ### Method static func ### Signature static func binaryTarget( name: String, path: String ) -> Target ### Parameters - **name** (String) - Required - The name of the target. - **path** (String) - Required - The path to the binary artifact. This path can point directly to a binary artifact or to an archive file that contains the binary artifact at its root. ### Returns Target - The created binary target. ### Notes Binary targets are only available on Apple platforms. ``` -------------------------------- ### CSetting.headerSearchPath(_:_:) Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Provides a header search path relative to the target's directory. Use this setting to add a search path for headers within your target. ```APIDOC ## CSetting.headerSearchPath(_:_:) ### Description Provides a header search path relative to the target's directory. Use this setting to add a search path for headers within your target. You can't use absolute paths and you can't use this setting to provide headers that are visible to other targets. The path must be a directory inside the package. ### Method static func headerSearchPath ### Parameters - **path** (String) - The path of the directory that contains the headers. The path is relative to the target's directory. - **condition** (BuildSettingCondition?) - A condition that restricts the application of the build setting. Optional. ### Availability First available in PackageDescription 5.0 ``` -------------------------------- ### static func macOS(_ version: SupportedPlatform.MacOSVersion) -> SupportedPlatform Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Configures the minimum deployment target version for the macOS platform using a predefined version type. Available since PackageDescription 5.0. ```APIDOC ## static func macOS(_ version: SupportedPlatform.MacOSVersion) -> SupportedPlatform ### Description Configures the minimum deployment target version for the macOS platform using a predefined version type. ### Method static func ### Signature `static func macOS(_ version: SupportedPlatform.MacOSVersion) -> SupportedPlatform` ### Parameters - **version** (SupportedPlatform.MacOSVersion) - Required - The minimum deployment target that the package supports. ### Availability - Since: PackageDescription 5.0 ### Returns A `SupportedPlatform` instance representing the configured platform. ``` -------------------------------- ### Package.Dependency.package(path:) Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Adds a local package dependency using a filesystem path. ```APIDOC ## Package.Dependency.package(path:) ### Description Adds a dependency to a local package on the filesystem. The Swift Package Manager uses the package dependency as-is and does not perform any source control access. ### Method static func ### Signature `static func package(path: String) -> Package.Dependency` ### Parameters - **path** (String) - Required - The path of the package. ``` -------------------------------- ### static func tvOS(_ version: SupportedPlatform.TVOSVersion) -> SupportedPlatform Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Configures the minimum deployment target version for the tvOS platform using a predefined version type. Available since PackageDescription 5.0. ```APIDOC ## static func tvOS(_ version: SupportedPlatform.TVOSVersion) -> SupportedPlatform ### Description Configures the minimum deployment target version for the tvOS platform using a predefined version type. ### Method static func ### Signature `static func tvOS(_ version: SupportedPlatform.TVOSVersion) -> SupportedPlatform` ### Parameters - **version** (SupportedPlatform.TVOSVersion) - Required - The minimum deployment target that the package supports. ### Availability - Since: PackageDescription 5.0 ### Returns A `SupportedPlatform` instance representing the configured platform. ``` -------------------------------- ### static func watchOS(_ version: SupportedPlatform.WatchOSVersion) -> SupportedPlatform Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Configures the minimum deployment target version for the watchOS platform using a predefined version type. Available since PackageDescription 5.0. ```APIDOC ## static func watchOS(_ version: SupportedPlatform.WatchOSVersion) -> SupportedPlatform ### Description Configures the minimum deployment target version for the watchOS platform using a predefined version type. ### Method static func ### Signature `static func watchOS(_ version: SupportedPlatform.WatchOSVersion) -> SupportedPlatform` ### Parameters - **version** (SupportedPlatform.WatchOSVersion) - Required - The minimum deployment target that the package supports. ### Availability - Since: PackageDescription 5.0 ### Returns A `SupportedPlatform` instance representing the configured platform. ``` -------------------------------- ### Resource.copy(_:) Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Documentation for the static method Resource.copy(_:) that copies a resource without processing. ```APIDOC ## Resource.copy(_:) ### Description Applies the copy rule to a resource at the given path. This rule copies resources as-is to the top level of the package's resource bundle, preserving the folder structure if the path is a directory. Use this rule when resources must remain untouched or retain a specific folder structure. ### Method static func ### Signature static func copy(_ path: String) -> Resource ### Parameters - **path** (String) - Required - The path for a resource. ### Return Value Resource - A resource value representing the copied resource. ### Discussion If possible, use `process(_:localization:)` instead to automatically apply optimizations. ``` -------------------------------- ### static func iOS(_ version: SupportedPlatform.IOSVersion) -> SupportedPlatform Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Configures the minimum deployment target version for the iOS platform using a predefined version type. Available since PackageDescription 5.0. ```APIDOC ## static func iOS(_ version: SupportedPlatform.IOSVersion) -> SupportedPlatform ### Description Configures the minimum deployment target version for the iOS platform using a predefined version type. ### Method static func ### Signature `static func iOS(_ version: SupportedPlatform.IOSVersion) -> SupportedPlatform` ### Parameters - **version** (SupportedPlatform.IOSVersion) - Required - The minimum deployment target that the package supports. ### Availability - Since: PackageDescription 5.0 ### Returns A `SupportedPlatform` instance representing the configured platform. ``` -------------------------------- ### Package.Dependency.package(url:from:) Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates a package dependency with a minimum version requirement, allowing updates up to the next major version. ```APIDOC ## Package.Dependency.package(url:from:) ### Description Creates a package dependency that uses the version requirement, starting with the given minimum version, going up to the next major version. This is the recommended way to specify a remote package dependency. ### Method static func ### Signature `static func package(url: String, from version: Version) -> Package.Dependency` ### Parameters - **url** (String) - Required - The valid Git URL of the package. - **version** (Version) - Required - The minimum version requirement. ### Example ```swift .package(url: "https://example.com/example-package.git", from: "1.2.3") ``` ``` -------------------------------- ### static func product(name:package:condition:) -> Target.Dependency Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates a target dependency on a product from a package dependency. Optionally, a condition can be provided to limit the application of the dependency. ```APIDOC ## static func product(name:package:condition:) -> Target.Dependency ### Description Creates a target dependency on a product from a package dependency. ### Method static func ### Signature ```swift static func product( name: String, package: String, condition: TargetDependencyCondition? = nil ) -> Target.Dependency ``` ### Parameters - **name** (String) - Required - The name of the product. - **package** (String) - Required - The name of the package. - **condition** (TargetDependencyCondition?) - Optional - A condition that limits the application of the target dependency. For example, only apply a dependency for a specific platform. ### Return Value - **Target.Dependency** - The created dependency. ``` -------------------------------- ### static func binaryTarget(name:url:checksum:) -> Target Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates a binary target that references a remote artifact. A binary target provides the url to a pre-built binary artifact for the target. Currently only supports artifacts for Apple platforms. ```APIDOC ## static func binaryTarget(name:url:checksum:) -> Target ### Description Creates a binary target that references a remote artifact. A binary target provides the url to a pre-built binary artifact for the target. Currently only supports artifacts for Apple platforms. ### Method static func ### Signature static func binaryTarget( name: String, url: String, checksum: String ) -> Target ### Parameters - **name** (String) - Required - The name of the target. - **url** (String) - Required - The URL to the binary artifact. This URL must point to an archive file that contains a binary artifact in its root directory. - **checksum** (String) - Required - The checksum of the archive file that contains the binary artifact. ### Returns Target - The created binary target. ### Notes Binary targets are only available on Apple platforms. ``` -------------------------------- ### static func define(_ name: String, to value: String? = nil, _ condition: BuildSettingCondition? = nil) -> CXXSetting Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Defines a value for a macro. If you don't specify a value, the macro's default value is 1. ```APIDOC ## static func define(_ name: String, to value: String? = nil, _ condition: BuildSettingCondition? = nil) -> CXXSetting ### Description Defines a value for a macro. If you don't specify a value, the macro's default value is 1. ### Method static func ### Signature `static func define(_ name: String, to value: String? = nil, _ condition: BuildSettingCondition? = nil) -> CXXSetting` ### Parameters - **name** (String) - Required - The name of the macro. - **value** (String?) - Optional - The value of the macro. If not specified, the default value is 1. - **condition** (BuildSettingCondition?) - Optional - A condition that restricts the application of the build setting. ### Availability First available in PackageDescription 5.0 ### Return Value CXXSetting - A CXX build setting that defines the macro. ``` -------------------------------- ### static func byName(name:condition:) -> Target.Dependency Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates a by-name dependency that resolves to either a target or a product after the Swift Package Manager has loaded the package graph. Optionally, a condition can be provided to limit the application of the dependency. ```APIDOC ## static func byName(name:condition:) -> Target.Dependency ### Description Creates a by-name dependency that resolves to either a target or a product but after the Swift Package Manager has loaded the package graph. ### Method static func ### Signature ```swift static func byName( name: String condition: TargetDependencyCondition? = nil ) -> Target.Dependency ``` ### Parameters - **name** (String) - Required - The name of the dependency, either a target or a product. - **condition** (TargetDependencyCondition?) - Optional - A condition that limits the application of the target dependency. For example, only apply a dependency for a specific platform. ### Return Value - **Target.Dependency** - The created dependency. ``` -------------------------------- ### static func exact(_ version: Version) -> Package.Dependency.Requirement Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Returns a requirement for the given exact version. Specifying exact version requirements is not recommended as it can cause conflicts in the dependency graph. Use version ranges instead. ```APIDOC ## static func exact(_ version: Version) -> Package.Dependency.Requirement ### Description Returns a requirement for the given exact version. Specifying exact version requirements is not recommended as it can cause conflicts in the dependency graph. Use version ranges instead. ### Method static func ### Signature `static func exact(_ version: Version) -> Package.Dependency.Requirement` ### Parameters - **version** (Version) - The exact version of the dependency for this requirement. ### Example ```swift .exact("1.2.3") ``` ``` -------------------------------- ### static func target(name:dependencies:path:exclude:sources:resources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:) -> Target Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates a regular target. A target can contain either Swift or C-family source files, but not both. It is built as a regular module that can be included in a library or executable product, but cannot be the main target of an executable product. ```APIDOC ## static func target(name:dependencies:path:exclude:sources:resources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:) -> Target ### Description Creates a regular target. A target can contain either Swift or C-family source files, but not both. It contains code that is built as a regular module that can be included in a library or executable product, but that cannot itself be used as the main target of an executable product. ### Method static func target ### Signature ```swift static func target( name: String, dependencies: [Target.Dependency] = [], path: String? = nil, exclude: [String] = [], sources: [String]? = nil, resources: [Resource]? = nil, publicHeadersPath: String? = nil, cSettings: [CSetting]? = nil, cxxSettings: [CXXSetting]? = nil, swiftSettings: [SwiftSetting]? = nil, linkerSettings: [LinkerSetting]? = nil ) -> Target ``` ### Parameters - **name** (String) - Required - The name of the target. - **dependencies** ([Target.Dependency]) - Optional - The dependencies of the target. A dependency can be another target in the package or a product from a package dependency. - **path** (String?) - Optional - The custom path for the target. By default, the Swift Package Manager requires a target's sources to reside at predefined search paths; for example, `[PackageRoot]/Sources/[TargetName]`. Don't escape the package root; for example, values like `../Foo` or `/Foo` are invalid. - **exclude** ([String]) - Optional - A list of paths to files or directories that the Swift Package Manager shouldn't consider to be source or resource files. A path is relative to the target's directory. This parameter has precedence over the `sources` parameter. - **sources** ([String]?) - Optional - An explicit list of source files. If you provide a path to a directory, the Swift Package Manager searches for valid source files recursively. - **resources** ([Resource]?) - Optional - An explicit list of resources files. - **publicHeadersPath** (String?) - Optional - The directory containing public headers of a C-family library target. - **cSettings** ([CSetting]?) - Optional - The C settings for this target. - **cxxSettings** ([CXXSetting]?) - Optional - The C++ settings for this target. - **swiftSettings** ([SwiftSetting]?) - Optional - The Swift settings for this target. - **linkerSettings** ([LinkerSetting]?) - Optional - The linker settings for this target. ### Return Value - **Target** - The created target. ``` -------------------------------- ### static func headerSearchPath(_ path: String, _ condition: BuildSettingCondition? = nil) -> CXXSetting Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Provides a header search path relative to the target's directory. Use this setting to add a search path for headers within your target. The path must be a directory inside the package. ```APIDOC ## static func headerSearchPath(_ path: String, _ condition: BuildSettingCondition? = nil) -> CXXSetting ### Description Provides a header search path relative to the target's directory. Use this setting to add a search path for headers within your target. You can't use absolute paths and you can't use this setting to provide headers that are visible to other targets. The path must be a directory inside the package. ### Method static func ### Signature `static func headerSearchPath(_ path: String, _ condition: BuildSettingCondition? = nil) -> CXXSetting` ### Parameters - **path** (String) - Required - The path of the directory that contains the headers. The path is relative to the target's directory. - **condition** (BuildSettingCondition?) - Optional - A condition that restricts the application of the build setting. ### Availability First available in PackageDescription 5.0 ### Return Value CXXSetting - A CXX build setting that adds the header search path. ``` -------------------------------- ### Package.Dependency.package(url:_:) Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Adds a package dependency with a half-open version range. ```APIDOC ## Package.Dependency.package(url:_:) ### Description Adds a package dependency starting with a specific minimum version, up to but not including a specified maximum version. ### Method static func ### Signature `static func package(url: String, _ range: Range) -> Package.Dependency` ### Parameters - **url** (String) - Required - The valid Git URL of the package. - **range** (Range) - Required - The custom version range requirement. ### Example ```swift .package(url: "https://example.com/example-package.git", "1.2.3"..<"1.2.6") ``` ``` -------------------------------- ### static func executableTarget(name:dependencies:path:exclude:sources:resources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:) -> Target Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates an executable target. An executable target can contain either Swift or C-family source files, but not both. It is built as an executable module that can be used as the main target of an executable product. ```APIDOC ## static func executableTarget(name:dependencies:path:exclude:sources:resources:publicHeadersPath:cSettings:cxxSettings:swiftSettings:linkerSettings:) -> Target ### Description Creates an executable target. An executable target can contain either Swift or C-family source files, but not both. It contains code that is built as an executable module that can be used as the main target of an executable product. The target is expected to either have a source file named `main.swift`, `main.m`, `main.c`, or `main.cpp`, or a source file that contains the `@main` keyword. ### Method static func executableTarget ### Signature ```swift static func executableTarget( name: String, dependencies: [Target.Dependency] = [], path: String? = nil, exclude: [String] = [], sources: [String]? = nil, resources: [Resource]? = nil, publicHeadersPath: String? = nil, cSettings: [CSetting]? = nil, cxxSettings: [CXXSetting]? = nil, swiftSettings: [SwiftSetting]? = nil, linkerSettings: [LinkerSetting]? = nil ) -> Target ``` ### Parameters - **name** (String) - Required - The name of the target. - **dependencies** ([Target.Dependency]) - Optional - The dependencies of the target. A dependency can be another target in the package or a product from a package dependency. - **path** (String?) - Optional - The custom path for the target. By default, the Swift Package Manager requires a target's sources to reside at predefined search paths; for example, `[PackageRoot]/Sources/[TargetName]`. Don't escape the package root; for example, values like `../Foo` or `/Foo` are invalid. - **exclude** ([String]) - Optional - A list of paths to files or directories that the Swift Package Manager shouldn't consider to be source or resource files. A path is relative to the target's directory. This parameter has precedence over the `sources` parameter. - **sources** ([String]?) - Optional - An explicit list of source files. If you provide a path to a directory, the Swift Package Manager searches for valid source files recursively. - **resources** ([Resource]?) - Optional - An explicit list of resources files. - **publicHeadersPath** (String?) - Optional - The directory containing public headers of a C-family library target. - **cSettings** ([CSetting]?) - Optional - The C settings for this target. - **cxxSettings** ([CXXSetting]?) - Optional - The C++ settings for this target. - **swiftSettings** ([SwiftSetting]?) - Optional - The Swift settings for this target. - **linkerSettings** ([LinkerSetting]?) - Optional - The linker settings for this target. ### Return Value - **Target** - The created target. ``` -------------------------------- ### static func testTarget(name:dependencies:path:exclude:sources:resources:cSettings:cxxSettings:swiftSettings:linkerSettings:) -> Target Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Creates a test target. Write test targets using the XCTest testing framework. Test targets generally declare a dependency on the targets they test. ```APIDOC ## static func testTarget(name:dependencies:path:exclude:sources:resources:cSettings:cxxSettings:swiftSettings:linkerSettings:) -> Target ### Description Creates a test target. Write test targets using the XCTest testing framework. Test targets generally declare a dependency on the targets they test. ### Method static func ### Signature static func testTarget( name: String, dependencies: [Target.Dependency] = [], path: String? = nil, exclude: [String] = [], sources: [String]? = nil, resources: [Resource]? = nil, cSettings: [CSetting]? = nil, cxxSettings: [CXXSetting]? = nil, swiftSettings: [SwiftSetting]? = nil, linkerSettings: [LinkerSetting]? = nil ) -> Target ### Parameters - **name** (String) - Required - The name of the target. - **dependencies** ([Target.Dependency]) - Optional - The dependencies of the target. A dependency can be another target in the package or a product from a package dependency. - **path** (String?) - Optional - The custom path for the target. By default, the Swift Package Manager requires a target's sources to reside at predefined search paths; for example, `[PackageRoot]/Sources/[TargetName]`. Don't escape the package root; for example, values like `../Foo` or `/Foo` are invalid. - **exclude** ([String]) - Optional - A list of paths to files or directories that the Swift Package Manager shouldn't consider to be source or resource files. A path is relative to the target's directory. This parameter has precedence over the `sources` parameter. - **sources** ([String]?) - Optional - An explicit list of source files. If you provide a path to a directory, the Swift Package Manager searches for valid source files recursively. - **resources** ([Resource]?) - Optional - An explicit list of resources files. - **cSettings** ([CSetting]?) - Optional - The C settings for this target. - **cxxSettings** ([CXXSetting]?) - Optional - The C++ settings for this target. - **swiftSettings** ([SwiftSetting]?) - Optional - The Swift settings for this target. - **linkerSettings** ([LinkerSetting]?) - Optional - The linker settings for this target. ### Returns Target - The created test target. ``` -------------------------------- ### CSetting.unsafeFlags(_:_:) Source: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html Sets unsafe flags to pass arbitrary command-line flags to the corresponding build tool. As the usage of the word 'unsafe' implies, the Swift Package Manager can't safely determine if the build flags have any negative side effect on the build. ```APIDOC ## CSetting.unsafeFlags(_:_:) ### Description Sets unsafe flags to pass arbitrary command-line flags to the corresponding build tool. As the usage of the word 'unsafe' implies, the Swift Package Manager can't safely determine if the build flags have any negative side effect on the build since certain flags can change the behavior of how it performs a build. As some build flags can be exploited for unsupported or malicious behavior, the use of unsafe flags make the products containing this target ineligible for use by other packages. ### Method static func unsafeFlags ### Parameters - **flags** ([String]) - The unsafe flags to set. - **condition** (BuildSettingCondition?) - A condition that restricts the application of the build setting. Optional. ### Availability First available in PackageDescription 5.0 ```