Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How I can properly add Path to swift manifest file #65

Closed
vkuznet opened this issue Aug 30, 2020 · 4 comments
Closed

How I can properly add Path to swift manifest file #65

vkuznet opened this issue Aug 30, 2020 · 4 comments

Comments

@vkuznet
Copy link

vkuznet commented Aug 30, 2020

Hi,
I tried to add Path to dependencies of Package.swift file and I'm getting this error if I list "Path" as target.dependecies["Path"].

Updating https://github.com/mxcl/Path.swift
Resolving https://github.com/mxcl/Path.swift at 1.2.0
'MyCode' /Users/vk/Work/Languages/Swift/MyCode: error: dependency 'Path' in target 'SwiftMLExample' requires explicit declaration; reference the package in the target dependency with '.product(name: "Path", package: "Path.swift")'

If I list it as

.target(dependencies[.product(name: "Path", package: "Path")])

I get this error: unknown package 'Path' in dependencies of target.

Can someone show example of Package.swift file where Path is included in dependencies? I'm new to swift.
Thanks,
Valentin.

@mxcl
Copy link
Owner

mxcl commented Aug 30, 2020

.target(dependencies[.product(name: "Path", package: "Path")])

Is not valid Swift, nor is it the correct syntax, I suggest letting Xcode do the completion for you.

.target(name: "Foo:", dependencies: [.product(name: "Path", package: "Path")])

@mxcl mxcl closed this as completed Aug 30, 2020
@vkuznet
Copy link
Author

vkuznet commented Aug 30, 2020

This is exactly what I have in my Package.swift (among other things):

        .target(
            name: "SwiftMLExample",
            dependencies: [
                "Just",
                .product(name: "Path", package: "Path"),
                .product(name: "ArgumentParser", package: "swift-argument-parser")
            ])

and, swift build throws this error:

/Users/vk/Work/Languages/Swift/SwiftMLExample: error: unknown package 'Path' in dependencies of target 'SwiftMLExample'

And, XCode is not universally available, e.g. there is no Xcode on Linux. So, I want to learn how to do it by hand. All other packages I used are working and Path some how does not.

Here is how to reproduce the problem with fresh environment:

  1. create new package with
swift package init --type executable
Creating executable package: TestPathVanila
Creating Package.swift
Creating README.md
Creating .gitignore
Creating Sources/
Creating Sources/TestPathVanila/main.swift
Creating Tests/
Creating Tests/LinuxMain.swift
Creating Tests/TestPathVanilaTests/
Creating Tests/TestPathVanilaTests/TestPathVanilaTests.swift
Creating Tests/TestPathVanilaTests/XCTestManifests.swift
  1. Add Path to dependencies, see my Package.swift
// swift-tools-version:5.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "TestPathVanila",
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
        .package(url: "https://github.com/mxcl/Path.swift", from: "1.2.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 which this package depends on.
        .target(
            name: "TestPathVanila",
            dependencies: [.product(name: "Path", package: "Path")]),
        .testTarget(
            name: "TestPathVanilaTests",
            dependencies: ["TestPathVanila"]),
    ]
)
  1. build package
swift build
/Users/vk/Work/Languages/Swift/tmp/TestPathVanila: error: unknown package 'Path' in dependencies of target 'TestPathVanila'

@mxcl
Copy link
Owner

mxcl commented Aug 30, 2020

.product(name: "Path", package: "Path.swift")

@vkuznet
Copy link
Author

vkuznet commented Aug 30, 2020

This works!
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants