软件包.依赖性没有成员包



我正在使用我的应用程序,并且在添加软件包时会遇到此错误。

error: type 'Package.Dependency' has no member 'Package'

这是我的软件包。Swift代码:

// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
    name: "xHelp",
    dependencies: [
        .Package(url: "https://github.com/onevcat/Hedwig.git",
                 majorVersion: 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: "xHelp",
            dependencies: ["Hedwig"]),
        .testTarget(
            name: "xHelpTests",
            dependencies: ["xHelp"]),
        ]
)

我尝试了这个帖子,但它没有用。我应该在这里做什么?

您应该这样写。

.package(url: "https://github.com/onevcat/Hedwig.git", from: "1.0.0"),

在我的情况下,我遇到了一个错误: type 'Target.Dependency' has no member 'package'。问题是,我将软件包声明放在目标依赖项之内,而不是顶级软件包依赖关系。

错误的软件包:

let package = Package(
    name: "PackageName",
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.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: "PackageName",
            dependencies: [.package(
                    url: "https://github.com/jpsim/Yams.git",
                    from: "1.0.1")]
        )
    ] 
)

固定

let package = Package(
    name: "PackageName",
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
        .package(
            url: "https://github.com/jpsim/Yams.git",
            from: "1.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: "PackageName",
            dependencies: []
        )
    ]
)

一切都可以,只能将资本p更改为p

中的p

.package(url:" https://github.com/onevcat/hedwig.git", 主要文章:1(

小写

.package(url:" https://github.com/onevcat/hedwig.git", 主要文章:1(

最新更新