Errors when importing Swift package into another Swift package

I have defined a local Swift package "Models". In this Swift package, I defined a dependency, which is another local Swift package, Apple's "swift-protobuf".

In "Models" I have Swift files generated from protobuf. They all include the import statement, "import SwiftProtobuf".

However, this import statement fails saying, "No such module 'SwiftProtobuf'", even though clearly SwiftProtobuf is shown in the Xcode sidebar and the local path to it is perfectly valid.

What can I do to fix this?

"Models" already has a Package.swift file that contains the line:
.package(path: "../../Carthage/Checkouts/swift-protobuf")

This is a valid path to my local copy of swift-protobuf. The rest of our app still uses Carthage so I'm having to declare the dependency this way for now.

Does your target declare that it depends on swift-protobuf? That’s separate from the package dependency.

Yeah that was the problem. Thanks!

1 Like