Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: could not find target(s): MyLib; use the 'path' property in the Swift 4 manifest to set a custom target path

I am running sudo swift test and got following error:

error: could not find target(s): MyLib; use the 'path' property in the Swift 4 manifest to set a custom target path

Package.swift:

// swift-tools-version:4.0

import PackageDescription

let package = Package(
    name: "MyLib",
    targets: [
        .target(name: "MyLib"),
        .testTarget(
            name: "MyLibTests",
            dependencies: ["MyLib"])
    ]
)
like image 293
Orkhan Alikhanov Avatar asked Oct 26 '17 00:10

Orkhan Alikhanov


1 Answers

According to the proposal there is an impact on exiting code. The purposal says:

These enhancements will be added to the version 4 manifest API, which will release with Swift 4. There will be no impact on packages using the version 3 manifest API. When packages update their minimum tools version to 4.0, they will need to update the manifest according to the changes in this proposal.

Since your minimum tools version is 4.0, you must add path: "path/to/sources" in .Target().

Your Package.swift should look like this:

// 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")
    ]
)
like image 61
Orkhan Alikhanov Avatar answered Nov 18 '22 08:11

Orkhan Alikhanov