Unstable `archive` for `Debug` configuration (ld: file cannot be open()ed, errno=2)

We have a relatively big iOS-only project with around 80 build targets from swift packages (local features and external project dependencies) and Xcode 15.4 (originally, migrated to 16.0). Project compiles and runs great, but xcodebuild archive will fail 4 out of 5 tries with this:

ld: file cannot be open()ed, errno=2 path=/opt/builds/fLLyxmhG/0/myapp/Build/Intermediates.noindex/ArchiveIntermediates/myapp (Development Flow)/BuildProductsPath/Debug-iphonesimulator/Account.o in '/opt/builds/fLLyxmhG/0/myapp/Build/Intermediates.noindex/ArchiveIntermediates/myapp (Development Flow)/BuildProductsPath/Debug-iphonesimulator/Account.o'

Where Account.o is an end product of one of our feature packages linking to an .app itself.

This error is not tied to this concrete package/product (which should be compiling almost last relative to build graph) and could appear mid-build in between our service layer packages.

It seems (and is approved by Xcode timeline for .app archive log) that module dependency is compiled later than module itself and linker just cant find its dependency object files. The scheme is:

  • Module A (dependency itself)
  • Module B (needs module A)

And with build order expected (???) to be A (first) -> B we're getting the B -> A.

Error appears only when archiving for Debug configuration, archiving the same end-target with Release configuration results in stable passes 10 out of 10 tries. Setting identical parameters in Build Settings tab for both configurations of a target is not giving any effect.

Our current fix is choosing Manual order in scheme Build order setting. Everything works as expected, but i guess it's not optimal 🤧

Sadly can't provide test project, but anything else — welcome.

Unstable `archive` for `Debug` configuration (ld: file cannot be open()ed, errno=2)
 
 
Q