How to manage a custom module.modulemap for a package

Hi,

I'm trying to adapt a Swift Package for an existing Objective C project. The project structure doesn't follow the SPM folder structure conventions and looks like this:

.
├── Frameworks
│ ├── GCDWebServers.h
│ ├── Info.plist
│ ├── Tests.m
├── GCDWebServer
│ ├── Core
│ │ ├── GCDWebServer.h
│ │ ├── GCDWebServer.m
│ │ ├── GCDWebServerConnection.h
│ │ ├── GCDWebServerConnection.m
│ │ ├── GCDWebServerFunctions.h
│ │ ├── GCDWebServerFunctions.m
│ │ ├── GCDWebServerHTTPStatusCodes.h
│ │ ├── GCDWebServerPrivate.h
│ │ ├── GCDWebServerRequest.h
│ │ ├── GCDWebServerRequest.m
│ │ ├── GCDWebServerResponse.h
│ │ └── GCDWebServerResponse.m
│ ├── Requests
│ │ ├── GCDWebServerDataRequest.h
│ │ ├── GCDWebServerDataRequest.m
│ │ ├── GCDWebServerFileRequest.h
│ │ ├── GCDWebServerFileRequest.m
│ │ ├── GCDWebServerMultiPartFormRequest.h
│ │ ├── GCDWebServerMultiPartFormRequest.m
│ │ ├── GCDWebServerURLEncodedFormRequest.h
│ │ └── GCDWebServerURLEncodedFormRequest.m
│ ├── Responses
│ │ ├── GCDWebServerDataResponse.h
│ │ ├── GCDWebServerDataResponse.m
│ │ ├── GCDWebServerErrorResponse.h
│ │ ├── GCDWebServerErrorResponse.m
│ │ ├── GCDWebServerFileResponse.h
│ │ ├── GCDWebServerFileResponse.m
│ │ ├── GCDWebServerStreamedResponse.h
│ │ └── GCDWebServerStreamedResponse.m

Defining the sources in the Package.swift isn't an issue, however I'm struggling with the public headers and the umbrella header (located at Frameworks/GCDWebServers.h).

The documentation mentions " In case of complicated include layouts, a custom module.modulemap can be provided inside include . SwiftPM will error out if it can not generate a modulemap with respect to the above rules.": https://github.com/apple/swift-package-manager/blob/master/Documentation/Usage.md

However I seem to fail to create a correct module.modulemap. The resulting module will be created and can be imported into a swift project (import GCDWebServers), but no symbols/classes are available.

Also I wasn't able to find any project that does something similar. Can anyone give me an example on how to implement the module.modulemap (ideally based on the example above)?

The module map would look something like this:

module GCDWebServer {
 header "PATHTO/Frameworks/GCDWebServers.h"
 export *
}

Then you should be able to Import the module from Swift:

import GCDWebServer
...
etcetera
...

I wrote about it some time ago. If you want to check an example, you can find it here:

https://rderik.com/blog/understanding-objective-c-and-swift-interoperability/