Reputation: 395
I am working on my app, and I keep getting this error when I add a package so I can import it.
error: type 'Package.Dependency' has no member 'Package'
This is my Package.swift code:
// 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"]),
]
)
I have tried this SO post, but it didn't work. What should I do here?
Upvotes: 6
Views: 3231
Reputation: 45
Everything its okay only change capital P to p in
.Package(url: "https://github.com/onevcat/Hedwig.git", majorVersion: 1)
to lowercase
.package(url: "https://github.com/onevcat/Hedwig.git", majorVersion: 1)
Upvotes: 1
Reputation: 9387
In my case, I was getting an error like: type 'Target.Dependency' has no member 'package'
. The issue was, I was putting the package declaration within the Target dependency, rather than the top level Package dependency.
Wrong Package.swift:
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")]
)
]
)
FIXED:
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: []
)
]
)
Upvotes: 4
Reputation: 126
You should write it like this.
.package(url: "https://github.com/onevcat/Hedwig.git", from: "1.0.0"),
Upvotes: 11