"No such module" when using SPM binaryTarget/XCFramework on dependency

My setup is as follows:

  • iOS App (Executable) implements Library A via SPM
    • Library A implements StaticLibrary B through .binaryTarget option
    • Library A imports StaticLibraryB in several swift files and compiles fine on it's own

The problem starts when I try to archive the iOS App as I always end up getting the error no such module 'StaticLibraryB' on the first of my swift files that import my StaticLibraryB in Library A.

The binaryTarget itself is a zipped xcframework and works fine when manually added to Xcode (not via Package.swift), so I don't think that is killing the compilation.

Looking at other posts, I've already tried putting the binaryTarget into it's own product via a new Package.swift file and then dropping the binaryTarget dependency to no avail. Importing StaticLibraryB with @_implementationOnly didn't fix it for me either.

Looking at my build log though, it seems that when Xcode invokes swift and SPM to compile LibraryA, it's not processing the xcframework correctly. I've seen this race condition happening before on it's own, where on a cached build SPM correctly uses the builtin-process-xcframework option to process XCFrameworks but not on clean builds. Unfortunately, I can't replicate this race condition here no matter how often I try to archive.

I'd appreciate any insights on how we could solve this issue to get past this point for compilation.


My team is experiencing exactly the same problem with the same setup. Happens with Xcode 13 too. It's also listed under "Known issues" in the release notes, so there is hope: Apple Developer Documentation

Is there any workaround for this issue?

Terms of Service

Privacy Policy

Cookie Policy