Xcode 11中没有这样的模块“ PackageDescription”

时间:2019-12-08 13:58:38

标签: ios xcode11 swift-package-manager

我有一个框架和库的现有项目,希望它们使用Swift Package Manager。

我有一个Xcode 11,并且已经读过Creating a Swift Package with Xcode

在将Package.swift添加到项目和应用程序目标中之后

import PackageDescription

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

我收到错误

  

没有这样的模块“ PackageDescription”

如何导入 PackageDescription 模块?

1 个答案:

答案 0 :(得分:0)

我刚刚在 very first line 文件的 Package.swift 下面添加了一行,它对我有用。

<块引用>

// swift-tools-version:4.0

注意:请不要在此行之前写任何内容甚至注释

之后不要忘记运行swift build命令