[Swift Package Manager] Framework with SPM dependencies has different behaviour if the dependencies are in Swift and objc

Hey, I found a different behaviour when generating a binary that uses SPM dependencies in objc and swift.
I'm not sure if this is a bug or if it's the intended behaviour.

Imagine that I have a framework called MyLibraryContainer.
This library is closed source, so I will distribute this framework as binary.

If I add to my framework a swift library A as dependency with SPM, and distribute a binary of MyLibraryContainer.framework, everything just works, because it seems that the swift library A it's inside MyLibraryContainer.

But If I add to my framework an objc library B as dependency with SPM, and distribute a binary of MyLibraryContainer.framework, I get an error while importing MyLibraryContainer Missing required module B.
To work around this issue, I need to integrate both MyLibraryContainer and B into the new project to avoid the Missing required module B error.

Is this a bug, or is there any restrictions on SPM related to objc libraries?

Thanks

It sounds like you are using Xcode (due to the words “framework” and “project”).

Unless you compile your code from the command line with $ swift build, SwiftPM isn’t actually building it.

If you are building with Xcode—even if Xcode is fetching some dependency code from a SwiftPM package—then the people you want to talk to are over on the Apple Developer Forums.

Yes, the framework is an Xcode project, and it's Xcode that is building the framework.
But since SPM was fetching the packages, I thought that this could be related to SPM.

Sadly, the number of bugs that occur in one but not the other seems to indicate that very little code is shared between the two. An Apple employee might know better, but from the outside it appears Xcode respects SwiftPM’s manifest specification, but reimplements everything itself.

Terms of Service

Privacy Policy

Cookie Policy