Swift linking error: type metadata accessor for Module.Class

I hope I'm getting this right but if I understand it correctly from your screenshot you seem to have two applications (projects with Mach-O Type: executable) in your workspace.

Is this so in your setup? Because that would present a problem: You generally can't import code from one application into the other.

You need to make "Feature" a Framework or Library rather than an app. Then you need to add it under "Frameworks and Libraries" on the General tab in your Base build target settings.

After that, all should be ok.


I had the same error after a long I found the solution that I had to add the not linked framework (library) to any target you important at General -> Frameworks and Libraries


Looking at your screenshot I tried to replicate this setup and got the same problem (I have to say that error message is a bit cryptic). So the problem is that you have two iOS app projects inside workspace. And while iOS app is a swift module, it is impossible to import one iOS app inside another one. What you can do, though, is to convert your Feature into framework, and then import that framework into Base app. Or extract SHCommon class into framework that both Feature and Base will import.

More about frameworks: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html