I have a Swift Framework which we compile and distribute to 3rd party developers. I want to include some C code into the project, but the only way I've been able to make it work is by importing the C header into my framework's header and setting the C header as public. This exposes all of the C code to the 3rd party developers which is not what we want.
Everything I can find online for how to do this is a variation of this method: https://spin.atomicobject.com/2015/02/23/c-libraries-swift/
But the caveat of this method is "Note that consumers of any frameworks you build using this technique are also going to have to add the module to their Swift search paths." And we've tried this and sure enough our 3rd party developers get an error Missing required module 'CGeodesic'
which is the module we've defined pointing to the C header.
How can we just compile the C code right into our framework while keeping the code private, and not requiring 3rd party developers to change their build settings in order to make it work? I don't mind having to setup these submodules in our project, but at the end of the day I want it compiled directly into a single flat framework binary, no dynamic linking or search paths or anything like that.
Edit
The project is C code side-by-side with Swift code. I have a subdirectory in my project that looks like this:
- Geodesic/
- Geodesic.h
- Geodesic.c
- Geodesic.swift
The Swift file wraps the C code to make it cleaner to work with. I had a module.modulemap file in that directory as well, but like I said previously that didn't work. I would prefer to keep the C code side-by-side with my Swift code but I'm willing to give that up in order to solve this issue.