I have compiled some C code and built a .dylib. I also have a C header for this .dylib.
I want to create a target for it in Swift Package Manager. I would then like to use that target as a dependency in a Swift only (source) package, so I can write/test a nicer way to do the C interop in Swift.
There are a lot of examples for system libraries, but I haven't found a single one for using a .dylib/C Header that I've created. Or they all are based on having the C source. I've searched for hours and am close to just giving up and opening a TSI.
If an example isn't available, answers to the following will help me move forward I think:
- Does SPM support bridging headers?
- Are system libraries the only way to use a .dylib?
- Does SPM support embedding a .dylib this way?
- To embed a .dylib, do I just add it as a
.copyresource in the "C" package?
- Do I need to add a
cSettingsflag for the dylib?
- Do I need a module map?
I should note I can't just drop the source in (of which there are some examples for) because this is actually a Ziglang project, that I am compiling to a .dylib and using the C ABI. I was able to use my .dylib and C header in a test macOS app, but can't seem to figure out how to access the code using SPM. So I don't think it's a problem with my Zig code.
I'm not a C programmer, so please forgive any incorrect terms/ideas. I'd love to make this work!