Importing a C/C++ library into your project
Here's an example of how to import a pre-built library into your Plain Swift project. This has been tested for C, should work for C++ as well.
Obtain pre-built library
Using C/C++ source files has not been tested yet, although it might work. This example uses a pre-built library, so you should get a ready-made library from the library developer or build it yourself. The library must be built using the same version of Microsoft Visual Studio that is used in your Swift toolkit. It's probably enough to match only the major versions. A pre-built library usually consists of .h, .lib and, optionally, .dll files.
Optionally enable C++ interoperability
If the imported library is written in C++, you need to enable C++ interoperability for your Plain Swift project. Select the File | Project Settings menu command and locate the Compiler section. Make sure that the C++ interoperability setting is set to Default, which means it is enabled. If the imported library is written in C, then you don't need to enable this setting.
Place library files in specific folders
Create include folder in your Plain Swift project folder (at the top level, next to the project.plainswift file);
Create lib folder in your Plain Swift project folder (at the top level, next to the project.plainswift file).
Place .h files in the include folder.
Place .lib files in the lib folder.
If your library is dynamic (rather than static), then you also have .dll files.
These are only needed at runtime.
Place them in the Release folder (it should exist if you have ever tried to build your project).
Create a Clang module
Create a module.modulemap file in the include folder. Edit the module.modulemap file to include a new module name (e.g. Forest), and all the required .h files in it (e.g. forest.h and tree.h):
module Forest { header "forest.h" header "tree.h" export * }Now you can import the Forest Clang module in your Plain Swift project source files:
import ForestIf your Plain Swift project is itself a Swift module (e.g. named Terrain), it will reexport the Forest Clang module, so that any project that import Terrain can also import Forest.