If LibG's swiftinterface contains import GComponent, I get the following error:
[...]/.build/x86_64-apple-macosx/debug/LibG.framework/Modules/LibG.swiftmodule/x86_64-apple-macos.private.swiftinterface:4:8: error: no such module 'GComponent'
If I only use @_implementationOnly import GComponent, the import doesn't appear in my swiftinterface and the code compiles, but I'd like to able to import the module in other code without resorting to Objective-C headers.
Is there something I'm missing in how to expose these modules to Swift?
(I'm going to assume that the first line is meant to be LibG.framework, not LibG.xcframework, since the file structure shown here is more analogous to the former.)
Due to the way module loading/searching is implemented w.r.t. frameworks on Apple platforms, a framework can only expose a single module and the framework's name must match the module's name. If you want to distribute LibG and GComponent in a way that clients can import either or both of them individually (if GComponent is not simply an implementation detail of LibG), then you must separate them into LibG.framework and GComponent.framework.
Thanks. That's a bit of a bummer. Do you know if there are workarounds either by fitting multiple frameworks in an xcframework or embedding GComponent as a full framework inside LibG.framework?
The thing I'm trying to avoid is having to distribute three zip files, LibG.xcframework.zip and GComponent.xcframework.zip for SPM and a combined zip for CocoaPods since it doesn't support multiple sources.
One thing to note, was curious to see if mergable libraries produced a novel solution here, but it doesn't. Merged frameworks don't contain modules for their dependencies, so you can't distribute a merged framework for development. Instead, the dependency graph in Xcode uses the modules from the mergable frameworks for compiling and the merged framework for distribution.
It's a matter of tradeoffs where either you're hosting more zip files or distributing more packages. I was hoping that the distinction between products and targets in Swift would let me avoid that complexity, but it's sadly not the case.