To create a custom module, we will begin by creating a directory to put all of its files in. This will be the module's main directory. Within this directory, we will need two files. The first is a file named Package.swift
, and the second is named module.modulemap
.
Within the module.modulemap
file we will define the headers we want to import and the libraries that we wish to link to. The following sample shows how the module.modulemap
file is formatted:
module CMyModule [system] { header "/usr/include/mylibheader.h" link "mylib" export * }
The first line defines the name of the module. This name is what we will import in our Swift files. In this sample, the module's name is CMyModule
. The next line defines the full path to the header file that we want to import. The third line is optional and tells the compiler that the functionality defined in the header can be found in the mylib
library, so we will need to link it. If we do not...