I'm trying to migrate an existing mixed (C++, C, Swift) library to SPM without breaking the existing Xcode-based setup. I managed to get pretty far by splitting the C, C++ and Swift code into modules, but I still have one problem. You'd have to actually import those modules before using them. Since Xcode is using the bridging header, it doesn't require any imports and symbols are available top level. Which means that for SPM, I need the imports and for Xcode, I don't, which breaks my initial plan of not breaking the Xcode setup.
Now, I might have found a couple of solutions:
- Create targets in the Xcode proj for C and C++ source code, essentially splitting the code per language like SPM does it. This is a bit hard to do because it fundamentally changes the way things are build.
- Use
@_exported import MyCorCppModule
in a file used only by SPM. This feels like a hack and there's a lot of controversy around it.
But, do I have any other options? If not, what's the better approach?