Couldn't find architectures linking static library

Question or problem

When running tuist generate I get the following error:

➜ mise exec -- tuist generate
Loading and constructing the graph
It might take a while if the cache is empty


▌ ✖ Error 
▌ Couldn't find architectures for binary at path /Users/xxxx/Developer/xxxx/xxxx/KDCReader/libKDCReader.a 
▌
▌ Sorry this didn’t work. Here’s what to try next: 
▌  ▸ If the error is actionable, address it
▌  ▸ If the error is not actionable, let's discuss it in the Troubleshooting & how to
▌  ▸ If you are very certain it's a bug, file an issue
▌  ▸ Check out the logs at /Users/xxxx/.local/state/tuist/logs/27D01F0C-C020-4F9F-AF7D-2096CBB109F5.log

When trying to add a static library dependency to my target.

Expectation

That I’m able to add a static library to my target in this way

Context

➜ mise exec -- tuist version
4.45.1

Contents of the log is:

➜ cat /Users/xxxx/.local/state/tuist/logs/27D01F0C-C020-4F9F-AF7D-2096CBB109F5
2025-03-28T08:56:53+1100 notice dev.tuist.cli : is=section Loading and constru
2025-03-28T08:56:53+1100 notice dev.tuist.cli : It might take a while if the c

The dependency is defined as:

.library(
    path: "KDCReader/libKDCReader.a",
    publicHeaders: "KDCReader/include",
    swiftModuleMap: "KDCReader/KDCReader.swiftmodule"
),

The module map looks like:

➜ cat KDCReader/KDCReader.swiftmodule
module KDCReader [system] {
    header "include/KDCReader.h"
    link "KDCReader"
    export *
}

Running lip -info on the binary gives me:

➜ lipo -info KDCReader/libKDCReader.a       
Architectures in the fat file: KDCReader/libKDCReader.a are: armv6 armv7 armv7s x86_64 arm64 

Reproduction (mandatory for problems)

This is hard to provide a reproduction for as this isn’t a sharable library. So I’m mainly looking for direction and if I’m seemingly doing the correct thing.

This might have something to do with it:

➜ xcodebuild -create-xcframework -library "KDCReader/libKDCReader.a" -headers "KDCReader/include/" -output KDCReader.xcframework
error: binaries with multiple platforms are not supported '/Users/xxxx/Developer/hds/hdsscan2/KDCReader/libKDCReader.a'

Hey :wave:

I’d recommend running tuist generate through Xcode using these steps: Get started · Contributors · Tuist

That way, you can add breakpoints during the tuist execution to see what’s going on. It would be useful if you could inspect the program here when getting the precompiled metadata for the static library you’re trying to integrate. It would be very useful to know what the output of NXGetArchInfoFromCpuType(cputype, cpusubtype) is in your case – and if it’s not nil, what its value is.

From what I can see this is most likely a bug in Tuist, so I can’t think of a workaround – and without a repro sample, I can’t look into this myself.

if the library is fat library (containing multiple arch, platform).
Normal dependency graph does not works properly.

In my experience you have two options.

  1. slice the library into each platform and arch. and declare it as library .library(...)

  2. use linker flag and specify library path manullay -ld KDCReader/libKDCReader.a. But I’m not sure How you can handle swiftmodule file in this case though…