首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >快速包:错误:没有找到包'LineNoise‘中的产品依赖’linenoise‘

快速包:错误:没有找到包'LineNoise‘中的产品依赖’linenoise‘
EN

Stack Overflow用户
提问于 2020-05-16 13:51:04
回答 1查看 1.4K关注 0票数 8

我使用Swift软件包管理器来管理我的项目中的依赖项。我正试图在我的快速包中导入LineNoise,但我得到了以下信息:

代码语言:javascript
复制
nathanfallet:SwiftMC nathanfallet$ swift run
Fetching https://github.com/andybest/linenoise-swift.git
Fetching https://github.com/Quick/Nimble.git
Fetching https://github.com/apple/swift-argument-parser
Fetching https://github.com/apple/swift-nio.git
Fetching https://github.com/adam-fowler/compress-nio.git
Cloning https://github.com/apple/swift-nio.git
Resolving https://github.com/apple/swift-nio.git at 2.17.0
Cloning https://github.com/adam-fowler/compress-nio.git
Resolving https://github.com/adam-fowler/compress-nio.git at 0.3.0
Cloning https://github.com/apple/swift-argument-parser
Resolving https://github.com/apple/swift-argument-parser at 0.0.6
Cloning https://github.com/andybest/linenoise-swift.git
Resolving https://github.com/andybest/linenoise-swift.git at 0.0.3
Cloning https://github.com/Quick/Nimble.git
Resolving https://github.com/Quick/Nimble.git at 7.3.4
'SwiftMC' /Users/nathanfallet/git/SwiftMC: error: product dependency 'LineNoise' in package 'linenoise-swift' not found

这不是我导入的第一个包,其他程序也在工作(我也是以同样的方式导入它们)。我和其他包一样将这个包添加到我的Package.swift文件中,但是这个包似乎不起作用.

我的Package.swift文件:

代码语言:javascript
复制
// 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: "SwiftMC",
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "SwiftMC",
            targets: ["SwiftMC"]),
        .executable(
            name: "SwiftMCRun",
            targets: ["SwiftMCRun"])
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"),
        .package(url: "https://github.com/adam-fowler/compress-nio.git", from: "0.0.1"),
        .package(url: "https://github.com/apple/swift-argument-parser", from: "0.0.1"),
        .package(url: "https://github.com/andybest/linenoise-swift.git", from: "0.0.1")
    ],
    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: "SwiftMC",
            dependencies: [
                .product(name: "NIO", package: "swift-nio"),
                .product(name: "CompressNIO", package: "compress-nio")
            ]),
        .target(
            name: "SwiftMCRun",
            dependencies: [
                "SwiftMC",
                .product(name: "ArgumentParser", package: "swift-argument-parser"),
                .product(name: "LineNoise", package: "linenoise-swift") // Error seems to come from here; I tried "linenoise", "LineNoise", "linenoise-swift" but nothing seems to work
            ]),
        .testTarget(
            name: "SwiftMCTests",
            dependencies: ["SwiftMC"]),
    ]
)

知道这是怎么回事吗?为什么这个包没有进口,而其他人呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-31 11:58:38

原因:

当包指定与github回购名称不同的Package.name属性时,会发生此问题。例如,LineNoise的回购名称是linenoise-swift,但LineNoise。您将注意到所有其他依赖项都有与package.swift包名称一致的github名称。

Fix:只是.package的包名

要解决这个问题,请在您的中显式地指定包依赖项的包名(您可以在库package.swift文件中找到该名称)。

代码语言:javascript
复制
// Latest prerelease
.package(name: "LineNoise", url: "https://github.com/andybest/linenoise-swift", from: "0.0.3")

现在,在目标依赖项中,可以使用LineNoise作为package参数。

另一个例子(Mapbox导航):

在使用MapBox导航库时,我遇到了类似的问题。而不是像我添加其他库那样使用添加,而是声明使用特定用途的文档

要在另一个包而不是应用程序中安装MapboxNavigation框架,请运行swift package init来创建Package.swift,然后添加以下依赖项:

代码语言:javascript
复制
// Latest prerelease
.package(name: "MapboxNavigation", url: "https://github.com/mapbox/mapbox-navigation-ios.git", .exact("2.0.0-beta.11"))

无论如何,看起来您的存储库不再使用lineNoise了。

对包开发人员的注意:

确保您的GitHub回购是相同的名称与您的包名,它将只是更方便。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61837852

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档