The following dependency graph causes non-deterministic build failures:
Xcode app -> MyProduct (dynamic library in MyPackage) -> MyTarget (Swift target in MyPackage) -> CMyTarget (C target in MyPackage) -> Binary target
In particular, CMyTarget occasionally fails to import the headers from the binary target. From my testing, this appears to be a race condition where the binary target's framework is not always extracted into the products directory before the C files using it are compiled.
I've attached a sample project demonstrating the bug (simply an iOS app with the aforementioned dependency graph). The issue only occurs on clean builds, and that too not always; quitting and re-opening Xcode also helps reproduce the bug. Re-building seems to fix the problem (because the framework is already in the products dir?), but that's unfortunately impractical for CI/CD setups.