Package.Dependency has no member Package

You should write it like this.

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

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: []
        )
    ]
)

Tags:

Ios

Swift