Is a modulemap file required when importing a static library objective-c framework? If not when is a modulemap required?

I am a bit confused. My understanding previously was that a modulemap was required in order to have a bridging header be generated. Now it has come to my attention that a modulemap is both a build input and something you can put in the Modules folder of the built product if you so choose.

I have tried reading the clang modulemap documentation, but am really struggling to connect most of what it says to the problem at hand.

In a project I am working on, the generation of the modulemap file is quite problematic. The framework imports C++ libraries and itself writes Objective-C++ wrappers for them. Currently, the modulemap file is both set as the Module Map File in "Build Settings" and presumably used when the Swift project later imports it.

In this project the modulemap is a list of the objective-c++ header files then export *

I am trying to understand what I would lose if I do one or both of two things:

  1. What happens if I dont set this module map file in the build settings for the objective-c++ framework?
  2. What happens if I dont have a modulemap involved whatsoever in this objective-c++ framework and then it is imported into Swift?

And does any of this change if its compiled as a static vs dynamic library? What if I embed it vs not embed it?

Because the build in the real project is so complicated its hard to isolate what is going on. So I built a smaller sample app.

There is CFramework which has an objective-c++ class. There is SwiftProject which imports that framework and is purely Swift. It imports the module and uses it.

I did not write a modulemap file, and the Swift project builds just fine. In the timeline it:

  1. Prepares packages
  2. Computes target dependency graph
  3. Builds static cache for iPhoneSimulator18.2sdk

As near as I can tell even though the objective-c++ framework is not built with a modulemap in its build settings and there is not a modulemap included in the framework everything works. So then the modulemap file is useless? Perhaps it speeds things up but what step would theoretically be skippable?

Is a modulemap file required when importing a static library objective-c framework? If not when is a modulemap required?
 
 
Q