# Having Very Strange Package Manager Dependency Chain Issues

**URL:** <https://forums.swift.org/t/having-very-strange-package-manager-dependency-chain-issues/37853>\
**Category:** Using Swift\
**Tags:** packagemanager\
**Created:** [June 24, 2020, 1:33pm UTC](https://forums.swift.org/t/having-very-strange-package-manager-dependency-chain-issues/37853 "2020-06-24T13:33:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisMarshallNY](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/chrismarshallny/32/12229_2.png) [@ChrisMarshallNY](https://forums.swift.org/u/ChrisMarshallNY)\
**Post date:** [June 24, 2020, 1:33pm UTC](https://forums.swift.org/t/having-very-strange-package-manager-dependency-chain-issues/37853/1 "2020-06-24T13:33:12Z")

</div>

_ **UPDATE** : I gave it a couple of days, with no answers, so I will be starting to modify the repos, in an effort to fix the problem (I'll get it, eventually)._

I am absolutely sure that "I'm not holding it right," but there's no way for me to diagnose the issue.

[I have also asked this question on Stack Overflow.](https://stackoverflow.com/questions/62558858/strange-dependency-issue-with-swift-package-manager)

I have this package[0], which is consumed by this package[1], which is, in turn, consumed by this app[2]. The first package[0] is also consumed by this package[3], which is also consumed by the app[2]. That chain works fine, but is also a great deal simpler.

The issue is that I get an error inside the RVS\_BlueThoth package[1] during the BlueVanClef[2] build.

The error is consistent with the RVS\_Generic\_Swift\_Toolbox[0] package not building in the RVS\_BlueThoth package[1] build (the module is not available), but I can't figure out why. There is nothing but a blank serialized diagnostics file for one of the files that consumes the RVS\_Generic\_Swift\_Toolbox[0] module, and no other errors, other than the file isn't there.

If I build the RVS\_BlueThoth package[1] independently, I have no issues, but including it in the BlueVanClef app[2] consistently reports this error.

Here is a visual map of the dependency relationships:

 ![SPMIssue](https://global.discourse-cdn.com/swift/original/2X/e/e7e5416db6b9cf7da420edf16c5a62ce4e4a4542.png)

Note the dotted line between RVS\_BlueThoth and RVS\_Persistent\_Prefs. That's because the dependency is only for test harnesses, and is not used by Blue Van Clef.

Like I said, I am sure that the problem is mine. I just can't figure out how to get to it.

Thanks for any help!

(For example, is there any diagnostic utility available for SPM?)

Here are the Package.swift files:

RVS\_Generic\_Swift\_Toolbox:

```
// swift-tools-version:5.2

import PackageDescription

let package = Package(
    name: "RVS_Generic_Swift_Toolbox",
    platforms: [
        .iOS(.v11),
        .tvOS(.v11),
        .macOS(.v10_14),
        .watchOS(.v5)
    ],
    products: [
        .library(
            name: "RVS-Generic-Swift-Toolbox",
            type: .dynamic,
            targets: ["RVS_Generic_Swift_Toolbox"])
    ],
    targets: [
        .target(
            name: "RVS_Generic_Swift_Toolbox",
            path: "./src")
    ]
)

```

RVS\_Peristent\_Prefs (This one works):

```
// swift-tools-version:5.2
import PackageDescription

let package = Package(
    name: "RVS_Persistent_Prefs",
    platforms: [
        .iOS(.v11),
        .tvOS(.v11),
        .macOS(.v10_14),
        .watchOS(.v5)
    ],
    products: [
        .library(
            name: "RVS-Persistent-Prefs",
            type: .dynamic,
            targets: ["RVS_Persistent_Prefs"])
    ],
    dependencies: [
        .package(
            url: "git@github.com:RiftValleySoftware/RVS_Generic_Swift_Toolbox.git",
            from: "1.2.1"
        )
    ],
    targets: [
        .target(
            name: "RVS_Persistent_Prefs",
            path: "./src")
    ]
)

```

RVS\_BlueThoth (This one does not work):

```
// swift-tools-version:5.2
import PackageDescription

let package = Package(
    name: "RVS_BlueThoth",
    platforms: [
        .iOS(.v11),
        .tvOS(.v11),
        .macOS(.v10_14),
        .watchOS(.v5)
    ],
    products: [
        .library(
            name: "RVS-BlueThoth",
            type: .dynamic,
            targets: ["RVS_BlueThoth"]
        )
    ],
    dependencies: [
        .package(
            url: "git@github.com:RiftValleySoftware/RVS_Generic_Swift_Toolbox.git",
            from: "1.2.1"
        ),
        .package(
            url: "git@github.com:RiftValleySoftware/RVS_PersistentPrefs.git",
            from: "1.1.1"
        )
    ],
    targets: [
        .target(
            name: "RVS_BlueThoth",
            path: "./src/Source"
        )
    ]
)

```

Because I am not allowed to have more than five links, here goes:

[[0]](https://github.com/RiftValleySoftware/RVS_Generic_Swift_Toolbox)  
[[1]](https://github.com/RiftValleySoftware/RVS_BlueThoth)  
[[2]](https://github.com/RiftValleySoftware/BlueVanClef)  
[[3]](https://github.com/RiftValleySoftware/RVS_PersistentPrefs)

---

<div class="post-metadata">

**Author:** ![ChrisMarshallNY](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/chrismarshallny/32/12229_2.png) [@ChrisMarshallNY](https://forums.swift.org/u/ChrisMarshallNY)\
**Post date:** [June 25, 2020, 6:01pm UTC](https://forums.swift.org/t/having-very-strange-package-manager-dependency-chain-issues/37853/2 "2020-06-25T18:01:50Z")

</div>

OK. Solved. Finally.

I was, indeed, "holding it wrong," but it was not easy to tell.

The best way to debug was to `cd` to the package directory, and do a `swift build`. That helped me to see the errors as they happened (They were not reflected in the Xcode logs).

The issue was that I needed to do the dependency in **TWO** places. I had it only in one. Now that I look back on it, it was a fairly natural structure, but was complicated by the fact that I needed to rename the product of the dependency to use dashes, instead of underscores.

This was fixed by changing the RVS\_BlueThoth Package.swift file to like so:

```
// swift-tools-version:5.2

import PackageDescription

let package = Package(
    name: "RVS_BlueThoth",
    platforms: [
        .iOS(.v11),
        .tvOS(.v11),
        .macOS(.v10_14),
        .watchOS(.v5)
    ],
    products: [
        .library(name: "RVS-BlueThoth", type: .dynamic, targets: ["RVS_BlueThoth"])
    ],
    dependencies: [
        .package(name: "RVS_Generic_Swift_Toolbox", url: "git@github.com:RiftValleySoftware/RVS_Generic_Swift_Toolbox.git", from: "1.2.1")
    ],
    targets: [
        .target(
            name: "RVS_BlueThoth",
            dependencies: [.product(name: "RVS-Generic-Swift-Toolbox", package: "RVS_Generic_Swift_Toolbox")],
            path: "./src/Source"
        )
    ]
)

```

The money shot was this line:

`dependencies: [.product(name: "RVS-Generic-Swift-Toolbox", package: "RVS_Generic_Swift_Toolbox")]`

Note that the `name` argument is `"RVS-Generic-Swift-Toolbox"`, NOT `"RVS_Generic_Swift_Toolbox"`, but the package name had the underscores (I probably could do without the `name` argument in the global dependency list).

That is because [I had to swap underscores for dashes in order to get the app to be accepted by the App Store](https://stackoverflow.com/questions/62477747/swift-package-manager-problem-with-bundle-ids).

_ **UPDATE:** _ _I wanted to mention that the thing that made it for me, was the error response from the `swift build` command. It was awesome. It actually had the code that I needed to use. It was that response that showed me that I need to use dashes, mixed with underscores. That was not something that I was understanding._

---

<div class="post-metadata">

**Author:** ![ChrisMarshallNY](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/chrismarshallny/32/12229_2.png) [@ChrisMarshallNY](https://forums.swift.org/u/ChrisMarshallNY)\
**Post date:** [July 6, 2020, 10:41am UTC](https://forums.swift.org/t/having-very-strange-package-manager-dependency-chain-issues/37853/3 "2020-07-06T10:41:37Z")

</div>

Just FYI. I have written up [a fairly comprehensive series](https://littlegreenviper.com/series/spm/) on implementing the SPM.

It draws from my experience converting a significant number of my projects to Swift Package Manager.

If I got anything wrong, I'd be grateful for any feedback.

Thanks!
