Orkhan Alikhanov
Orkhan Alikhanov

Reputation: 10050

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

Upvotes: 13

Views: 10044

Answers (1)

Orkhan Alikhanov
Orkhan Alikhanov

Reputation: 10050

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

Upvotes: 22

Related Questions