How does SPM link dependencies exactly?

So I am trying to get a better understanding of the swift build system, and I'm noticing that SPM seems to handle modules very differently than XCode.

So for instance, if I create an XCode project from a swift package using swift package generate-xcodeproj, then each module gets built as a framework. This is fairly easy to understand.

But I'm having a little bit of trouble understanding how SPM is building things. For instance, if I build an executable, it looks like the individual object files which have been built per-source-file from the dependencies are linked into the final product via the Objects.LinkFileList.

So my questions are;

  1. Am I understanding this correctly?

  2. What is the advantage of handling it this way vs. building libraries per module like XCode appears to?

1 Like