Local packages don't necessarily require dependencies for all of their imports?

I'm in the process of using SPM local packages to break up a monolithic iOS app.

I'm using swift-tools-version:5.2 in Xcode 11.4.1.

Package HigherLevel has a file that does an import LowerLevel.

I discovered that I can build HigherLevel even if I don't declare an explicit dependency on LowerLevel in Package.swift. (That's true even if I make HigherLevel my build target in Xcode and clean before I build.)

Maybe that's because HigherLevel also depends on package MidLevel, and MidLevel also imports LowerLevel.

Even if that's true, though, it's not consistent; HigherLevel must declare dependencies on some other packages that MidLevel also imports.

This is, of course, confusing. What's worse, I can't rely on a visual inspection of Package.swift to know which packages HigherLevel uses.

What am I missing?


PS This also happens with non-local dependencies. For example, package LowerLevel declares a dependency on SwiftProtobuf via its GitHub URL; package HigherLevel can "import SwiftProtobuf" without declaring a dependency on SwiftProtobuf itself.

You are not missing anything, this is by design. This thread has some more information.