2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PackageDescription.mdの和訳

Last updated at Posted at 2019-07-16

これを読むついでに和訳した。

Package

パッケージ型は名称、プロダクト、ターゲット、依存関係、そしてパッケージの他の様々な部分を設定するために利用されます。

慣例により、 Packageのプロパティは単一のネストされた初期化ステートメントで定義されています。
そして、初期化後には変更されません。例えば次のようになります。

// swift-tools-version:5.0
import PackageDescription

let package = Package(
    name: "MyLibrary",
    platforms: [
        .macOS(.v10_14),
    ],
    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"]),
    ]
)

Methods


Package(
    name: String,
    platforms: [SupportedPlatform]? = nil,
    products: [Product] = [],
    dependencies: [Package.Dependency] = [],
    targets: [Target] = [],
    swiftLanguageVersions: [SwiftVersion]? = nil,
    cLanguageStandard: CLanguageStandard? = nil,
    cxxLanguageStandard: CXXLanguageStandard? = nil
)

About the Swift Tools Version

Package.swiftマニフェストファイルは、文字列 // swift-tools-version:で始まり、その後にバージョン番号指定子が続く必要があります。

Examples:

// swift-tools-version:3.0.2
// swift-tools-version:3.1
// swift-tools-version:4.0
// swift-tools-version:5.0

Swift toolsバージョンは、 PackageDescriptionライブラリのバージョン、マニフェストを処理するためのSwiftツールの最小バージョンとSwift言語互換バージョン、そしてSwiftパッケージを使用するために必要なSwiftツールの最小バージョンを宣言します。

Swiftの各バージョンは PackageDescriptionライブラリへの更新を導入できますが、以前のAPIバージョンは以前のツールバージョンを宣言するパッケージで引き続き利用可能です。

この動作により、パッケージのマニフェストの更新や既存パッケージへのアクセスを失うことなく、Swift、Swiftツール、そして PackageDescriptionライブラリの新しいリリースを利用できます。

SupportedPlatform

パッケージによってサポートされているプラットフォームを表します。

デフォルトでは、Swift Package Managerは platform APIを使って設定されていない限り、サポートされている各プラットフォーム用にあらかじめ定義された最低限のデプロイメントバージョンを割り当てます。

この定義済みデプロイメントバージョンは、特定のプラットフォーム用にインストールされたSDKによってサポートされる最も古いデプロイメントターゲットバージョンになります。

この規則の1つの例外はmacOSです。この場合、最小デプロイメントターゲットバージョンは10.10から始まります。

パッケージは、この構造体で定義されているAPIを使用して、プラットフォームの最小デプロイメントターゲットバージョンを設定することを選択できます。

サポートされているプラットフォームに無効な値、つまり空の配列、同じプラットフォームに対する複数の宣言、または無効なバージョン指定が指定された場合、Swift Package Managerは適切なエラーを生成します。

依存関係が最上位パッケージのデプロイメントバージョンと互換性がない場合、Swift Package Managerはエラーを生成します。依存関係のデプロイメントターゲットは、特定のプラットフォームの最上位パッケージのデプロイメントターゲットバージョン以下である必要があります。

Methods

/// Configure the minimum deployment target version for the macOS platform.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameter version: The minimum deployment target that the package supports.
static func macOS(_ version: SupportedPlatform.MacOSVersion) -> SupportedPlatform

/// Configure the minimum deployment target version for the macOS platform
/// using a custom version string.
///
/// The version string must be a series of 2 or 3 dot-separated integers, for
/// example "10.10" or "10.10.1".
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameter versionString: The minimum deployment target as a string representation of 2 or 3 dot-separated integers, e.g. "10.10.1".
static func macOS(_ versionString: String) -> SupportedPlatform

/// Configure the minimum deployment target version for the iOS platform.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameter version: The minimum deployment target that the package supports.
static func iOS(_ version: SupportedPlatform.IOSVersion) -> SupportedPlatform

/// Configure the minimum deployment target version for the iOS platform
/// using a custom version string.
///
/// The version string must be a series of 2 or 3 dot-separated integers, for
/// example "8.0" or "8.0.1".
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameter versionString: The minimum deployment target as a string representation of 2 or 3 dot-separated integers, e.g. "8.0.1".
static func iOS(_ versionString: String) -> SupportedPlatform

/// Configure the minimum deployment target version for the tvOS platform.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameter version: The minimum deployment target that the package supports.
static func tvOS(_ version: SupportedPlatform.TVOSVersion) -> SupportedPlatform

/// Configure the minimum deployment target version for the tvOS platform
/// using a custom version string.
///
/// The version string must be a series of 2 or 3 dot-separated integers, for
/// example "9.0" or "9.0.1".
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameter versionString: The minimum deployment target as a string representation of 2 or 3 dot-separated integers, e.g. "9.0.1".
static func tvOS(_ versionString: String) -> SupportedPlatform

/// Configure the minimum deployment target version for the watchOS platform.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameter version: The minimum deployment target that the package supports.
static func watchOS(_ version: SupportedPlatform.WatchOSVersion) -> SupportedPlatform

/// Configure the minimum deployment target version for the watchOS platform
/// using a custom version string.
///
/// The version string must be a series of 2 or 3 dot-separated integers, for
/// example "2.0" or "2.0.1".
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameter versionString: The minimum deployment target as a string representation of 2 or 3 dot-separated integers, e.g. "3.0.1".
static func watchOS(_ versionString: String) -> SupportedPlatform

Product

パッケージプロダクトを定義します。

パッケージプロダクトは、パッケージのクライアントが利用できる外部から見えるビルド成果物を定義します。
プロダクトは、パッケージの1つ以上のターゲットのビルド成果物から構築されます。

パッケージプロダクトは、次の2つのタイプのいずれかになります。

  1. ライブラリ

    ライブラリプロダクトは、クライアントが利用できるパブリックAPIを含むライブラリターゲットを提供するために使用されます。

  2. 実行可能ファイル

    実行可能ファイルプロダクトは、実行可能ターゲットを提供するために使用されます。
    これは、実行可能ファイルをクライアントが利用できるようにする必要がある場合にのみ使用してください。

次の例は、複数のプロダクトを定義する "Paper"というライブラリのパッケージマニフェストを示しています。

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"),
            ])
    ]
)

Methods

/// このパッケージに依存するクライアントが使用できるライブラリプロダクトを作成します。
///
/// ライブラリプロダクトは静的、または動的にリンクできます。
/// Swift Package Managerがパッケージのコンシューマーに応じて静的または動的リンクを選択できるように、
/// ライブラリのタイプを明示的に宣言しないことをお勧めします。
///
/// - Parameters:
///     - name: ライブラリプロダクトの名前
///     - type: ライブラリへのリンク方法を決定するために使用されるライブラリのオプションタイプ
///         このパラメーターを指定しないでおくと、Swift Package Managerが静的または動的リンクを選択できるようになります(推奨)。
///         両方のリンケージタイプをサポートしていない場合は、このパラメーターに「.static」または「.dynamic」を使用します。
///     - targets: ライブラリプロダクトにバンドルされているターゲット。
public static func library(
    name: String,
    type: Product.Library.LibraryType? = nil,
    targets: [String]
) -> Product

/// Create an executable product.
///
/// - Parameters:
///     - name: The name of the executable product.
///     - targets: The targets that are bundled into an executable product.
public static func executable(name: String, targets: [String]) -> Product

Package Dependency

パッケージの依存関係は、パッケージのソースへのGit URLと、使用できるパッケージのバージョンに対する要件から構成されます。

Swift Package Managerは依存関係解決と呼ばれるプロセスを実行して、パッケージで使用できるパッケージ依存関係の正確なバージョンを把握します。

依存関係の解決の結果は、パッケージのトップレベルディレクトリに置かれる Package.resolvedファイルに記録されます。

Methods

/// Add a package dependency that is required from the given minimum version,
/// going up to the next major version. 
///
/// This is the recommend way to specify a remote package dependency because
/// it allows you to specify the minimum version you require and gives
/// explicit opt-in for new major versions, but otherwise provides maximal
/// flexibility on which version is used. This helps to prevent conflicts in
/// your package dependency graph.
///
/// For example, specifying
///
///    .package(url: "https://example.com/example-package.git", from: "1.2.3"),
///
/// will allow the Swift package manager to select a version like a "1.2.3",
/// "1.2.4" or "1.3.0" but not "2.0.0".
///
/// - Parameters:
///     - url: The valid Git URL of the package.
///     - version: The minimum version requirement.
public static func package(url: String, from version: Version) -> Package.Dependency

/// Add a remote package dependency given a version requirement.
///
/// - Parameters:
///     - url: The valid Git URL of the package.
///     - requirement: A dependency requirement. See static methods on `Package.Dependency.Requirement` for available options.
public static func package(url: String, _ requirement: Package.Dependency.Requirement) -> Package.Dependency

///
/// For example
///
///     .package(url: "https://example.com/example-package.git", "1.2.3"..<"1.2.6"),
///
/// will allow the Swift package manager to pick versions 1.2.3, 1.2.4, 1.2.5, but not 1.2.6.
///
/// - Parameters:
///     - url: The valid Git URL of the package.
///     - range: The custom version range requirement.
public static func package(url: String, _ range: Range<Version>) -> Package.Dependency

/// Add a package dependency starting with a specific minimum version, going
/// up to and including a specific maximum version.
///
/// For example
///
///     .package(url: "https://example.com/example-package.git", "1.2.3"..."1.2.6"),
///
/// will allow the Swift package manager to pick versions 1.2.3, 1.2.4, 1.2.5, as well as 1.2.6.
///
/// - Parameters:
///     - url: The valid Git URL of the package.
///     - range: The closed version range requirement.
public static func package(url: String, _ range: ClosedRange<Version>) -> Package.Dependency

/// Add a dependency to a local package on the filesystem.
///
/// The package dependency is used as-is and no source control access is
/// performed. Local package dependencies are especially useful during
/// development of a new package or when working on multiple tightly-coupled
/// packages.
///
/// - Parameter path: The path of the package.
public static func package(path: String) -> Package.Dependency

Package Dependency Requirement

enum Package.Dependency.Requirement

依存関係の要件は、3つの異なるバージョン要件のうちの1つとして定義できます。

  1. バージョンベースの要件

    利用可能なバージョンに基づいて、パッケージが使用できる依存関係のバージョンを制限する要件。

    新しいパッケージバージョンが公開されたときに、後方互換性のない変更がある場合は、メジャーバージョンコンポーネントをインクリメントする必要があります。

    下位互換性のある方法で新しい機能を追加する場合は、マイナーバージョンコンポーネントをインクリメントする必要があります。 そして、後方互換性のあるバグ修正をするなら、それはパッチのバージョンを増やすべきです。

    セマンティックバージョニング構文の構文の詳細については、「Version」を参照するか、https://semver.orgにアクセスしてください。

  2. ブランチベースの要件

    依存関係が従うブランチ名を指定してください。

    これは、密接に関連している複数のパッケージを開発するときに役立ちます。
    開発中にそれらを同期させることができます。

    ブランチベースの依存関係要件を使用するパッケージは、バージョンベースの依存関係要件を使用するパッケージに依存することはできません。

    パッケージのバージョンを公開する前に、ブランチベースの依存関係要件を削除する必要があります。

  3. コミットベースの要件

    依存関係を特定のコミットハッシュに制限する要件。

    パッケージを依存関係の特定のコミットハッシュに固定したい場合に便利です。

    コミットベースの依存関係要件を使用するパッケージは、バージョンベースの依存関係要件を使用するパッケージに依存することはできません。 パッケージのバージョンを公開する前に、コミットベースの依存関係要件を削除する必要があります。

Methods

/// Returns a requirement for the given exact version.
///
/// Specifying exact version requirements are usually not recommended, as
/// they can cause conflicts in your package dependency graph when a package
/// is depended on by multiple other packages.
///
/// Example:
///
///   .exact("1.2.3")
///
/// - Parameters:
///      - version: The exact version to be specified.
public static func exact(_ version: Version) -> Package.Dependency.Requirement

/// Returns a requirement for a source control revision. This is usually
/// specified with the hash of a commit.
///
/// Note that packages which use commit-based dependency requirements
/// cannot be depended-upon by packages which use version-based dependency
/// requirements; you should remove commit-based dependency requirements
/// before publishing a version of your package.
///
/// Example:
///
///   .revision("e74b07278b926c9ec6f9643455ea00d1ce04a021")
///
/// - Parameters:
///     - ref: The Git revision, usually a hash of the commit.
public static func revision(_ ref: String) -> Package.Dependency.Requirement

/// Returns a requirement for a source control branch.
///
/// Note that packages which use branch-based dependency requirements
/// cannot be depended-upon by packages which use version-based dependency
/// requirements; you should remove branch-based dependency requirements
/// before publishing a version of your package.
///
/// Example:
///
///    .branch("develop")
///
/// - Parameters:
///     - name: The name of the branch.
public static func branch(_ name: String) -> Package.Dependency.Requirement

/// Returns a requirement for a version range, starting at the given minimum
/// version and going up to the next major version.
///
/// - Parameters:
///     - version: The minimum version for the version range.
public static func upToNextMajor(from version: Version) -> Package.Dependency.Requirement

/// Returns a requirement for a version range, starting at the given minimum
/// version and going up to the next minor version.
///
/// - Parameters:
///     - version: The minimum version for the version range.
public static func upToNextMinor(from version: Version) -> Package.Dependency.Requirement

Version

セマンティックバージョンを表す構造体。

セマンティックバージョニングは、バージョン番号の割り当て方法と増分方法を規定した一連の規則と要件を提案する仕様です。

セマンティックバージョニングの仕様の詳細については、次のWebサイトをご覧ください。
www.semver.org

Semantic Versioning (SemVer) 2.0.0

The Major Version

メジャーバージョンは、既存のクライアントを更新する必要があるAPIの破壊的変更をを意味します。

たとえば、既存の型名の変更、メソッド削除、メソッドのシグネチャを変更は破壊的変更とみなされます。

これには、後方互換性のないバグ修正や既存のAPIの動作変更も含まれます。

The Minor Version

機能が下位互換性のある方法で追加されている場合は、マイナーバージョンを更新します。

たとえば、他のAPIを変更せずに新しいメソッドや型を追加することは、下位互換性があると見なされます。

The Patch Version

下位互換があるバグ修正をする場合は、パッチのバージョンを上げてください。

これにより、クライアントはメンテナンスの負担を負うことなく、パッケージのバグ修正から恩恵を得ることができます。

Target

ターゲットはパッケージの基本的な構成要素です。

各ターゲットには、モジュールまたはテストスイートにまとめられた一連のソースファイルが含まれています。

ターゲットを含むプロダクトを定義することで、ターゲットを他のパッケージに提供できます。

ターゲットは、同じパッケージ内のターゲットおよび、そのパッケージの依存関係によって提供されているプロダクトに依存する場合があります。

Methods

/// Create a library or executable target.
///
/// A target can either contain Swift or C-family source files. You cannot
/// mix Swift and C-family source files within a target. A target is
/// considered to be an executable target if there is a `main.swift`,
/// `main.m`, `main.c` or `main.cpp` file in the target's directory. All
/// other targets are considered to be library targets.
///
/// - Parameters:
///   - name: The name of the target.
///   - dependencies: The dependencies of the target. These can either be other targets in the package or products from package dependencies.
///   - path: The custom path for the target. By default, targets will be looked up in the <package-root>/Sources/<target-name> directory.
///       Do not escape the package root, i.e. values like "../Foo" or "/Foo" are invalid.
///   - exclude: A list of paths to exclude from being considered source files. This path is relative to the target's directory.
///   - sources: An explicit list of source files.
///   - publicHeadersPath: The directory containing public headers of a C-family family library target.
///   - cSettings: The C settings for this target.
///   - cxxSettings: The C++ settings for this target.
///   - swiftSettings: The Swift settings for this target.
///   - linkerSettings: The linker settings for this target.
public static func target(
    name: String,
    dependencies: [Target.Dependency] = [],
    path: String? = nil,
    exclude: [String] = [],
    sources: [String]? = nil,
    publicHeadersPath: String? = nil,
    cSettings: [CSetting]? = nil,
    cxxSettings: [CXXSetting]? = nil,
    swiftSettings: [SwiftSetting]? = nil,
    linkerSettings: [LinkerSetting]? = nil
) -> Target

/// Create a test target.
///
/// Test targets are written using the XCTest testing framework. Test targets
/// generally declare target dependency on the targets they test.
///
/// - Parameters:
///   - name: The name of the target.
///   - dependencies: The dependencies of the target. These can either be other targets in the package or products from other packages.
///   - path: The custom path for the target. By default, targets will be looked up in the <package-root>/Sources/<target-name> directory.
///       Do not escape the package root, i.e. values like "../Foo" or "/Foo" are invalid.
///   - exclude: A list of paths to exclude from being considered source files. This path is relative to the target's directory.
///   - sources: An explicit list of source files.
///   - cSettings: The C settings for this target.
///   - cxxSettings: The C++ settings for this target.
///   - swiftSettings: The Swift settings for this target.
///   - linkerSettings: The linker settings for this target.
public static func testTarget(
    name: String,
    dependencies: [Target.Dependency] = [],
    path: String? = nil,
    exclude: [String] = [],
    sources: [String]? = nil,
    cSettings: [CSetting]? = nil,
    cxxSettings: [CXXSetting]? = nil,
    swiftSettings: [SwiftSetting]? = nil,
    linkerSettings: [LinkerSetting]? = nil
) -> Target

/// Create a system library target.
///
/// System library targets are used 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) and exposed to Swift packages by
/// providing a modulemap file along with other metadata such as the library's 
/// pkg-config name.
///
/// - Parameters:
///   - name: The name of the target.
///   - path: The custom path for the target. By default, targets will be looked up in the <package-root>/Sources/<target-name> directory.
///       Do not escape the package root, i.e. values like "../Foo" or "/Foo" are invalid.
///   - pkgConfig: The name of the pkg-config file for this system library.
///   - providers: The providers for this system library.
public static func systemLibrary(
    name: String,
    path: String? = nil,
    pkgConfig: String? = nil,
    providers: [SystemPackageProvider]? = nil
) -> Target

Target Dependency

class Target.Dependency

パッケージ内の他のターゲットまたは他のパッケージからのプロダクトへの依存関係を表します。

/// A dependency on a target in the same package.
public static func target(name: String) -> Target.Dependency

/// A dependency on a product from a package dependency.
public static func product(name: String, package: String? = nil) -> Target.Dependency

// A by-name dependency that resolves to either a target or a product,
// as above, after the package graph has been loaded.
public static func byName(name: String) -> Target.Dependency

CSetting

C言語のビルド設定

Methods

/// Provide a header search path relative to the target's directory.
///
/// Use this setting to add a search path for headers within your target.
/// Absolute paths are disallowed and this setting can't be used to provide
/// headers that are visible to other targets.
///
/// The path must be a directory inside the package.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameters:
///   - path: The path of the directory that should be searched for headers. The path is relative to the target's directory.
///   - condition: A condition which will restrict when the build setting applies.
public static func headerSearchPath(_ path: String, _ condition: BuildSettingCondition? = nil) -> CSetting

/// Defines a value for a macro. If no value is specified, the macro value will
/// be defined as 1.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameters:
///   - name: The name of the macro.
///   - value: The value of the macro.
///   - condition: A condition which will restrict when the build setting applies.
public static func define(_ name: String, to value: String? = nil, _ condition: BuildSettingCondition? = nil) -> CSetting

/// Set 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 will have any negative
/// side-effect to the build since certain flags can change the behavior of
/// how a build is performed.
///
/// As some build flags could be exploited for unsupported or malicious
/// behavior, the use of unsafe flags make the products containing this
/// target ineligible to be used by other packages.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameters:
///   - flags: The flags to set.
///   - condition: A condition which will restrict when the build setting applies.
public static func unsafeFlags(_ flags: [String], _ condition: BuildSettingCondition? = nil) -> CSetting

CXXSetting

C++言語のビルド設定

Methods

/// Provide a header search path relative to the target's root directory.
///
/// Use this setting to add a search path for headers within your target.
/// Absolute paths are disallowed and this setting can't be used to provide
/// headers that are visible to other targets.
///
/// The path must be a directory inside the package.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameters:
///   - path: The path of the directory that should be searched for headers. The path is relative to the target's directory.
///   - condition: A condition which will restrict when the build setting applies.
public static func headerSearchPath(_ path: String, _ condition: BuildSettingCondition? = nil) -> CXXSetting

/// Defines a value for a macro. If no value is specified, the macro value will
/// be defined as 1.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameters:
///   - name: The name of the macro.
///   - value: The value of the macro.
///   - condition: A condition which will restrict when the build setting applies.
public static func define(_ name: String, to value: String? = nil, _ condition: BuildSettingCondition? = nil) -> CXXSetting

/// Set 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 will have any negative
/// side-effect to the build since certain flags can change the behavior of
/// how a build is performed.
///
/// As some build flags could be exploited for unsupported or malicious
/// behavior, the use of unsafe flags make the products containing this
/// target ineligible to be used by other packages.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameters:
///   - flags: The flags to set.
///   - condition: A condition which will restrict when the build setting applies.
public static func unsafeFlags(_ flags: [String], _ condition: BuildSettingCondition? = nil) -> CXXSetting

SwiftSetting

Swift言語のビルド設定

Methods

/// Define a compilation condition.
///
/// Compilation conditons are used inside to conditionally compile
/// statements. For example, the Swift compiler will only compile the
/// statements inside the `#if` block when `ENABLE_SOMETHING` is defined:
///     
///    #if ENABLE_SOMETHING
///       ...
///    #endif
///
/// Unlike macros in C/C++, compilation conditions don't have an
/// associated value.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameters:
///   - name: The name of the macro.
///   - condition: A condition which will restrict when the build setting applies.
public static func define(_ name: String, _ condition: BuildSettingCondition? = nil) -> SwiftSetting

/// Set 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 will have any negative
/// side-effect to the build since certain flags can change the behavior of
/// how a build is performed.
///
/// As some build flags could be exploited for unsupported or malicious
/// behavior, the use of unsafe flags make the products containing this
/// target ineligible to be used by other packages.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameters:
///   - flags: The flags to set.
///   - condition: A condition which will restrict when the build setting applies.
public static func unsafeFlags(_ flags: [String], _ condition: BuildSettingCondition? = nil) -> SwiftSetting

LinkerSetting

リンカのビルド設定

Methods

/// Declare linkage to a system library.
///
/// This setting is most useful when the library can't be linked
/// automatically (for example, C++ based libraries and non-modular
/// libraries).
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameters:
///   - library: The library name.
///   - condition: A condition which will restrict when the build setting applies.
public static func linkedLibrary(_ library: String, _ condition: BuildSettingCondition? = nil) -> LinkerSetting

/// Declare linkage to a framework.
///
/// This setting is most useful when the framework can't be linked
/// automatically (for example, C++ based frameworks and non-modular
/// frameworks).
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameters:
///   - framework: The framework name.
///   - condition: A condition which will restrict when the build setting applies.
public static func linkedFramework(_ framework: String, _ condition: BuildSettingCondition? = nil) -> LinkerSetting

/// Set 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 will have any negative
/// side-effect to the build since certain flags can change the behavior of
/// how a build is performed.
///
/// As some build flags could be exploited for unsupported or malicious
/// behavior, the use of unsafe flags make the products containing this
/// target ineligible to be used by other packages.
///
/// - Since: First available in PackageDescription 5.0
///
/// - Parameters:
///   - flags: The flags to set.
///   - condition: A condition which will restrict when the build setting applies.
public static func unsafeFlags(_ flags: [String], _ condition: BuildSettingCondition? = nil) -> LinkerSetting

SwiftVersion

パッケージ内のSwiftソースをコンパイルするために使用すべきSwift言語のバージョンを表します。

public enum SwiftVersion {

    @available(_PackageDescription, introduced: 4, obsoleted: 5)
    case v3

    @available(_PackageDescription, introduced: 4)
    case v4

    @available(_PackageDescription, introduced: 4)
    case v4_2

    @available(_PackageDescription, introduced: 5)
    case v5

    /// User-defined value of Swift version.
    ///
    /// The value is passed as-is to Swift compiler's `-swift-version` flag.
    case version(String)
}

CLanguageStandard

サポートされているC言語標準

public enum CLanguageStandard {
    case c89
    case c90
    case iso9899_1990
    case iso9899_199409
    case gnu89
    case gnu90
    case c99
    case iso9899_1999
    case gnu99
    case c11
    case iso9899_2011
    case gnu11
}

CXXLanguageStandard

サポートされているC++言語標準

public enum CXXLanguageStandard {
    case cxx98 = "c++98"
    case cxx03 = "c++03"
    case gnucxx98 = "gnu++98"
    case gnucxx03 = "gnu++03"
    case cxx11 = "c++11"
    case gnucxx11 = "gnu++11"
    case cxx14 = "c++14"
    case gnucxx14 = "gnu++14"
    case cxx1z = "c++1z"
    case gnucxx1z = "gnu++1z"
}
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?