# Package issue - Unnecessary dependencies and wrong name?

**URL:** <https://forums.swift.org/t/package-issue-unnecessary-dependencies-and-wrong-name/46952>\
**Category:** Using Swift\
**Tags:** swift-package\
**Created:** [March 27, 2021, 7:31am UTC](https://forums.swift.org/t/package-issue-unnecessary-dependencies-and-wrong-name/46952 "2021-03-27T07:31:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nashysolutions](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nashysolutions/32/15433_2.png) [@nashysolutions](https://forums.swift.org/u/nashysolutions)\
**Post date:** [March 27, 2021, 7:31am UTC](https://forums.swift.org/t/package-issue-unnecessary-dependencies-and-wrong-name/46952/1 "2021-03-27T07:31:13Z")

</div>

Hi.

I'm having an issue with the following package.

There are two products. I just want to use the 'Jaws' library.

I expect the dependency 'Files' only but I'm also getting swift-argument-parser? And the package appears as Vice.

 ![1](https://global.discourse-cdn.com/swift/original/3X/8/e/8e6a785782be359d8d1b62ec7b40814eb5ecf995.jpeg)

```
let package = Package(
    name: "Vice",
    platforms: [.macOS(.v10_13)],
    products: [
        .executable(name: "vice", targets: ["Vice"]),
        .library(name: "Jaws", targets: ["Jaws"])
    ],
    dependencies: [
        .package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "0.3.0")),
        .package(url: "https://github.com/JohnSundell/Files.git", .upToNextMinor(from: "4.2.0")),
    ],
    targets: [
        .target(
            name: "Vice",
            dependencies: [
                .product(name: "ArgumentParser", package: "swift-argument-parser"),
                .product(name: "Files", package: "Files"),
                .target(name: "Jaws")
            ]),
        .target(
            name: "Jaws",
            dependencies: [
                .product(name: "Files", package: "Files")
            ]),
        .testTarget(
            name: "JawsTests",
            dependencies: [
                .product(name: "Files", package: "Files"),
                .target(name: "Jaws")
            ],
            resources: [
                .process("Resources")
            ]
        ),
    ]
)

```

---

<div class="post-metadata">

**Author:** ![SDGGiesbrecht](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sdggiesbrecht/32/4768_2.png) [@SDGGiesbrecht](https://forums.swift.org/u/SDGGiesbrecht)\
**Post date:** [March 27, 2021, 8:42am UTC](https://forums.swift.org/t/package-issue-unnecessary-dependencies-and-wrong-name/46952/2 "2021-03-27T08:42:29Z")

</div>

> [@nashysolutions](#):
>
> I expect the dependency 'Files' only but I'm also getting swift-argument-parser?

Your expectation matches the eventual intent for the how the package manager is to behave. However, the more fine‐grained resolution logic capable of recognizing `swift-argument-parser` as superfluous is not active in any official release yet. Swift 5.3 only knows to skip dependencies _not used by any product_.

Note that SwiftPM has only fetched the source code. It is not being compiled or in any way included in your build.

> [@nashysolutions](#):
>
> And the package appears as Vice.

The first screenshot you included is displaying a list of fetched _packages_. Expanding it shows all of the fetched source files, not just the ones relevant to the build. This is on purpose, so that read‐me and other included documentation is available in that menu. “Vice” _is_ the the name of the package, so it is displaying correctly.

The second screenshot is listing of _products_ available to link, which is why you see the product name “Jaws” instead.

---

<div class="post-metadata">

**Author:** ![nashysolutions](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nashysolutions/32/15433_2.png) [@nashysolutions](https://forums.swift.org/u/nashysolutions)\
**Post date:** [March 27, 2021, 12:08pm UTC](https://forums.swift.org/t/package-issue-unnecessary-dependencies-and-wrong-name/46952/3 "2021-03-27T12:08:40Z")

</div>

Thank you.

---

<div class="post-metadata">

**Author:** ![nashysolutions](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nashysolutions/32/15433_2.png) [@nashysolutions](https://forums.swift.org/u/nashysolutions)\
**Post date:** [March 27, 2021, 12:53pm UTC](https://forums.swift.org/t/package-issue-unnecessary-dependencies-and-wrong-name/46952/4 "2021-03-27T12:53:57Z")

</div>

What's also curious @SDGGiesbrecht is that the target `JawsTests` can only be run by the scheme `Vice-Package`. However, the tests are specific to the `Jaws` library and have nothing to do with the `Vice` target.

Is there a means of adjust the `PackageDescription` above to achieve a more specific test target?

---

<div class="post-metadata">

**Author:** ![SDGGiesbrecht](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sdggiesbrecht/32/4768_2.png) [@SDGGiesbrecht](https://forums.swift.org/u/SDGGiesbrecht)\
**Post date:** [March 27, 2021, 11:00pm UTC](https://forums.swift.org/t/package-issue-unnecessary-dependencies-and-wrong-name/46952/5 "2021-03-27T23:00:51Z")

</div>

Only the `x-Package` scheme is “real” in that it matches command line and cross‐platform SwiftPM. As a convenience, Xcode derives several others it thinks might be useful during development. But Xcode is closed source and I don’t know what its logic is. The manifest you posted appears to follow standard best practices, so if Xcode doesn’t already give you the sort of scheme you are looking for, I doubt there is a way to convince it to, at least from the manifest. You could try asking about it from the Xcode side over on the Apple Developer Forms.

---

<div class="post-metadata">

**Author:** ![SDGGiesbrecht](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sdggiesbrecht/32/4768_2.png) [@SDGGiesbrecht](https://forums.swift.org/u/SDGGiesbrecht)\
**Post date:** [April 11, 2021, 11:52pm UTC](https://forums.swift.org/t/package-issue-unnecessary-dependencies-and-wrong-name/46952/6 "2021-04-11T23:52:34Z")

</div>

> [@SDGGiesbrecht](#):
>
> Your expectation matches the eventual intent for the how the package manager is to behave. However, the more fine‐grained resolution logic capable of recognizing `swift-argument-parser` as superfluous is not active in any official release yet. Swift 5.3 only knows to skip dependencies _not used by any product_ .

[@nashysolutions [over on GitHub](https://github.com/apple/swift-package-manager/pull/3045#issuecomment-817289375):]

> As you can see, I am wondering around GitHub like a nomad, trying to find out more. You guys know if this issue has been raised already?

There is a bug registered [here](https://bugs.swift.org/browse/SR-8658), although it contains little information because work on it has revolved more around the [evolution proposal](https://github.com/apple/swift-evolution/blob/main/proposals/0226-package-manager-target-based-dep-resolution.md#package-manager-target-based-dependency-resolution) than the bug report.

The fix is actually already implemented, it’s just not live. I implemented it in [this pull request](https://github.com/apple/swift-package-manager/pull/2749) and it was merged. Unfortunately it ran into another bug that mishandles some packages and had to be temporarily disabled and hidden behind a compiler condition (by [this pull request](https://github.com/apple/swift-package-manager/pull/2998)). At this point, all the known packages which trigger the bug are confidential. Since I am not cleared to see them, I cannot reproduce the bug and cannot debug it. Apple’s employees have done some debugging of their own and from what they were able to say publicly, it seems the bug might actually have to do with package identity and caching instead, and may have only been exposed by the new code. For now I am crossing my fingers that it might have fixed itself by the time the identity overhaul is complete, and that at that point all we will have to do is remove the compiler condition. I think the most recent discussion is in [this pull request](https://github.com/apple/swift-package-manager/pull/3162), from which you should be able to follow links to find all the others.

It will not be included in Swift 5.4. I am hoping it will be in Swift 5.5.

---

<div class="post-metadata">

**Author:** ![tejassharma96](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tejassharma96/32/20111_2.png) [@tejassharma96](https://forums.swift.org/u/tejassharma96)\
**Post date:** [October 22, 2021, 7:24pm UTC](https://forums.swift.org/t/package-issue-unnecessary-dependencies-and-wrong-name/46952/7 "2021-10-22T19:24:38Z")

</div>

Sorry for the bump, but curious if this made it to 5.5 or not. I don't see any github PRs for re-enabling it but figured I'd ask here. If I'm understanding [this pull request](https://github.com/apple/swift-package-manager/pull/2998) correctly, `ENABLE_TARGET_BASED_DEPENDENCY_RESOLUTION` is something that needs to be set when compiling the swift toolchains, and not something we could use in an Xcode project. Is that correct?

---

<div class="post-metadata">

**Author:** ![SDGGiesbrecht](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sdggiesbrecht/32/4768_2.png) [@SDGGiesbrecht](https://forums.swift.org/u/SDGGiesbrecht)\
**Post date:** [October 22, 2021, 8:40pm UTC](https://forums.swift.org/t/package-issue-unnecessary-dependencies-and-wrong-name/46952/8 "2021-10-22T20:40:47Z")

</div>

Correct. Setting it _when you build the swift package manager_ enables the built package manager to do the experimental skipping.
