我正在运行sudo swift test并收到以下错误:



Package.swift:

// swift-tools-version:4.0

import PackageDescription

let package = Package(
    name: "MyLib",
    targets: [
        .target(name: "MyLib"),
        .testTarget(
            name: "MyLibTests",
            dependencies: ["MyLib"])
    ]
)

最佳答案

根据proposal,对现有代码有影响。目的是说:



由于您的最低工具版本4.0,因此必须在path: "path/to/sources"中添加.Target()

您的Package.swift应该如下所示:

// swift-tools-version:4.0

import PackageDescription

let package = Package(
    name: "MyLib",
    targets: [
        .target(
           name: "MyLib",
           path: "Sources"), //path for target to look for sources
        .testTarget(
            name: "MyLibTests",
            dependencies: ["MyLib"],
            path: "Tests")
    ]
)

关于swift4 - 错误: could not find target(s): MyLib; use the 'path' property in the Swift 4 manifest to set a custom target path,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46943952/

10-12 17:08