Xcode failing to build targets that depend on packages with local transitive dependencies

I'm struggling to set up an Xcode target using SPM. I'm becoming increasingly convinced that I'm hitting an Xcode bug. But, because I've created everything involved, there's always the possibility that there's an issue with my configuration or package set up.

Here's the scenario:

I would like to build a static library target in Xcode. It needs to depend on a SPM package. I do not want to link against the package, only build against it.

That package internally vends Library, made of up TargetA, which depends on TargetB.

When building, I get this error:

error: missing required module 'TargetB'
import Library
   ^
Command EmitSwiftModule failed with a nonzero exit code

Adding the package to the "Link with Binary Libraries" step resolves this error. But, that introduces linking problems in a downstream target, and isn't an option for me.

Interestingly, the Library > TargetA > TargetB setup appears to be the issue. I've tested packages that do not have dependent targets, and those work without linking. From Xcode's build log, it does appear that TargetB is built first, then TargetA, and then my static lib. Yet, this error crops up. I filed this with a project that reproduces it as FB10032666.

Does anyone have any insights on this problem?

3 Likes

cc @NeoNacho