How to use Objective C library in SPM project?

All the information I can find about using Objective C from swift assumes XCode. How can I do this with just SPM (I'm on Linux)? I have a library compiled to *.a static library file that is written in Objective C I would like to use in my SPM project. I can use systemLibrary to import C code, but it chokes on ObjC definitions in the header, and nothing else I do seems to get picked up at all.

If I understand correctly, there is no Objective-C runtime on Linux, so this cannot work. Objective-C code doesn't run on Linux.


GNUStep does exist, but Swift doesn't support it. There was a project to add support for it, but it appears to not have had any progress for a few years.

1 Like

So, does that mean that Objective-C code can run on linux, it's just that with the existing tooling Swift can't statically link an Objective-C library directly without going through, say, a C wrapper?

The Objective C code already complies and runs fine on Linux, so that's not the issue. I just don't know how to get SPM to expose the header in the Swift code.