Compiling/linking issues with the swift-collections-benchmark example in its docs

I am working through the example in the docs at, and having some trouble reproducing the example that @lorenty included there. I realized there was some Package.swift machinations that were needed to try it all out, so I created a basic one, and am running into some linking issues that are confusing me.

I made a project Kalimba (just in the Docs directory) with just the extension on Sequence within it, added the dependencies, and was trying to compile it - but swift run -c release kalimba-benchmark run --cycles 3 results returned the error:

/Users/heckj/src/swift-collections-benchmark/Documentation/.build/x86_64-apple-macosx/release/ error: header '/Users/heckj/src/swift-collections-benchmark/Documentation/.build/x86_64-apple-macosx/release/' not found
    header "/Users/heckj/src/swift-collections-benchmark/Documentation/.build/x86_64-apple-macosx/release/"
/Users/heckj/src/swift-collections-benchmark/Documentation/Sources/kalimba-benchmark/main.swift:2:8: error: could not build Objective-C module 'Kalimba'
import Kalimba

I assumed it was due to interlinking with Foundation in some fashion since the example is an extension on Sequence, so I added a nearly-do-nothing Kalimba.h file into the Sources.

Then trying the same command (swift run -c release kalimba-benchmark run --cycles 3 results) resulted in a linking error:

Undefined symbols for architecture x86_64:
  "_$sST7KalimbaE14kalimbaOrderedSay7ElementQzGyF", referenced from:
      _$s17kalimba_benchmarkySaySiGcfU_ in main.swift.o
ld: symbol(s) not found for architecture x86_64
[0/1] Linking kalimba-benchmark

I demangled that to:

(extension in Kalimba):Swift.Sequence.kalimbaOrdered() -> [A.Element]

But I'm a bit lost on what the underlying issue is. Is this ringing a bell with anyone?

I have the code in a branch on Github (GitHub - heckj/swift-collections-benchmark at docExample). Can anyone a bit more familiar here explain what I'm hitting with the linking errors, or possibly have some suggestions for how to get the example working?

Your Package.swift is missing the dependency edge between kalimba-benchmark and Kalimba. Since you had Kalimba already built, the import declaration still worked, but SwiftPM didn't pass the Kalimba library to the linker. (It would be cool if SwiftPM parsed through the linker error message and figured this out for you based on the module name "Kalimba" in the mangled name, but that's a bit much to ask when the linker's not providing machine-readable error messages.)

I don't know if that's going to be the only issue in your experiments, because I don't entirely understand the first error, but I think it'll get you further at least.


Thank you! That resolved it. And once I added in the dependency, the Kalimba.h header file didn't seem to be required either.

1 Like

I filed a bug for the erroneous missing-header error message when I was missing a dependency (

Terms of Service

Privacy Policy

Cookie Policy