"Missing required module" for C target of SwiftPM dependency within a .framework

If you've seen my previous post, this is somewhat related in that it's about the same project, but my previous post is still unanswered. You don't need to read it if you haven't; I've moved on from my previous approach for now.


I have built my Swift package, Jsum, as .framework using a project generated with Tuist. My package/framework depends on Echo, another Swift package by @Alejandro. Echo defines one product (itself) and two targets: Echo and CEcho.

My framework builds successfully. However when I add it to another project and try to link it, I get the following error: Missing required module 'CEcho'

But I'm not using CEcho! As far as I can tell, anyway. Poke around in Jsum's source code and see for yourself. I don't even expose any Echo types in public methods, types, or extensions in Jsum AFAICT.

But as Jsum depends on Echo, and Echo depends on CEcho… Am I doing something wrong? Do I need to compile CEcho separately and include that as a framework as well or something? That is not at all obvious, if true.


Any and all help is appreciated :pray: I have uploaded an example project with my framework embedded here as a ZIP if anyone feels like debugging it themselves.


I'm reposting this as I posted originally around Christmas time and in hindsight that was probably a mistake. My original post got zero responses. I'm still hopeful someone can help me, though.


Solution

@_implementationOnly import Echo does the trick. Credit: /u/ios_game_dev

Do you have any special reason to use the compiled framework file?
I can compile successfully using SPM.

I need to use it in an environment where SPM is not available

Sounds like Echo is statically linked in your Jsum framework but CEcho is not, and since Echo needs CEcho, it fails. Echo also depends on swift-atomics, which is probably also statically linked (or the compiler just stopped at the first error and that would also need to be fixed)

I don't use tuist but based on this this use case should be supported: iOS app with a dynamic framework that links a static framework · Examples · References · Tuist

Maybe it doesn't work properly when you are using Tuist with Package.swift or you are using Tuist incorrectly

You can also just ship all the 4 targets as dynamic/mergeable libraries if you also want to support the use case where the containing app depends on other stuff that also depend on Echo or swift-atomics.

Solution: @_implementationOnly import Echo in my code :raised_hands:t2:


@Cyberbeni I'm not sure why CEcho wouldn't be statically linked. I think it's just not getting put into the swift interface for some reason.

Regardless, thanks for the help and ideas :pray: