Creating a Mac/Linux multiplatform Swift package wrapping a static C library

I'm attempting to create a Swift package that wraps the librclone library, but includes binary files for both Linux and Mac, in both arm64 and amd64 architectures. (Might include iOS at a later date.)

I'm able to build all the artifacts (.a and .h files for each platform). I'm having trouble building cross-platform, so I have to build each manually on it's own OS/architecture, but that's a Go issue and not relevant here.

But I'm having trouble figuring out how to package them all together with SPM and wondering if it's not really possible.

I know that if I was just targeting Apple platforms I could build an xcframework file.

I also found that if you want to deliver a Mac/Linux binary, you can instead use an Artifact Bundle. But as far as I can find it doesn't support libraries, only executables.

Anything I'm missing or overlooking?

Very curious about this as well. What are the best practices of creating a Swift Package that ships with a static C-library binaryTarget?

It's been awhile since I looked at it but I think I might have done this with

I might be able to summarize but not today!

Hope this helps.

NOPE NOPE... this is the dynamic version.

1 Like