How to statically link a Swift framework to a Swift framework?

I have 2 frameworks, which are both Swift Statically-linked frameworks.

This means that my Mach-O Type is Static Library for both of the targets.

One of the targets (A) depends on another target (B).

I successfully archive A, and then I successfully archive B, linking against A. Embedding is enabled, however I don't seem to find any mentions of A in the exported build artifacts.

However, when I import archived and exported B in another target, it gives me a compilation error:

ld: warning: Could not find or use auto-linked framework 'A'
Undefined symbols for architecture x86_64:
  "A.someMethodInsideA() -> Swift.Int", referenced from:
  B.someMethodInsideB() -> Swift.Int in B(B.o)
ld: symbol(s) not found for architecture x86_64

You see, I set the A's Mach-O Type to Static Library, so I expect A's binaries to be completely embedded into B with static linkage, but this doesn't happen for some reason.

How can I embed a static framework inside a static framework?

Replies

If A was a library that was built to be linked dynamically (at least if it was a dynamically-linked Framework), then the symbols and the implementation of B would be copied into A automatically.

But if it needs to stay a statically linked library, then Perform Single-Object Prelink build setting might just do the trick!