SPM Package文件

149 阅读1分钟

Swift Package Manager 配置文件

Swift Package 有一些默认的路径。例如include/ Sources/ 等。

import PackageDescription

let package = Package(
    name: "PUMBLELibrary",
    products: [
        // Products define the executables 
        // and libraries a package produces, and make them 
        // visible to other packages.
        .library(
            name: "PUMBLELibrary",
            type: .static,
            targets: ["PUMBLELibrary"]),
    ],
    dependencies: [
        // Dependencies declare other packages 
        // that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
        .package(path: "../../third/SnapKit")
        .package(url: "xxxx.git", .upToNextMajor(from: "5.6.0"))
    ],
    targets: [
        // Targets are the basic building blocks of a package. 
        // A target can define a module or a test suite.
        // Targets can depend on other targets in this package, 
        // and on products in packages this package depends on.
        .target(
            name: "PUMBLELibrary",
            // 一来的第三方
            dependencies: ["xxx"],
            path: "Sources",
            publicHeadersPath: "../Sources",
            linkerSettings: [
                .linkedFramework("CoreBluetooth")
            ]),
            resources: [
                    .copy("./xxx.txt")
                ],
                swiftSettings:[
                    .define("SPM")
                ]),
        .testTarget(
            name: "PUMBLELibraryTests",
            dependencies: ["PUMBLELibrary"]),
    ],
    swiftLanguageVersions: [
        .v5
    ]
)