I’m running into a problem integrating a C-based library with our project using Tuist.
Right now, the library is included in our project as a Swift Package, and it works as expected. When using Tuist though, I’m getting some errors related to importing headers. The problem seems to revolve around the headers being contained within a subdirectory.
The problem is that with this current structure, the build fails because it the code within the library directory can’t seem to find the headers in the coollib directory. The headers are imported like this:
#include "coollib/important_header.h"
If I remove the coollib/ part from the import, things work as expected, so it seems to be not correctly finding things in that subdirectory.
Does anyone have advice on how to resolve this?
P.S. I’d prefer to find a solution that does not include modifying the directory structure, but if that’s the only way, then I can make that work if necessary.
@marekfort, Any tips for how one would then import this C library into an Xcode target correctly in the Tuist manifests? The library now builds correctly, but whenever I try to import it into a Swift target, it says “No such module”.
For a C library, you need to manually provide a modulemap (see here) which should be the missing piece. You will also need to instruct Swift where to find the modulemap file by adding -Xcc -fmodule-map-file $SRCROOT/path-to-your-modulemap. Alternatively, wrap the C library in a module and provide a MODULEMAP_FILE.
Other useful resource is our modulemap mapper where we translate MODULEMAP_FILE to compiler flags for downstream targets (which is something that would happen automatically in a pure SPM setup)