Best way to get modulemap module names programmatically?

One way to detect this is that SwiftPM creates a .pcm file for every module in the used module maps in the build directory .build/debug/ModuleCache/, so you could look for what files are in there and dump each pcm file with swiftc -dump-pcm, then check the fields Module map file: and Module name: from that output for all the module names from the module map you want to know about.

I and others have been asking for years for a way to dump the list of C/C++ symbols imported by a module map too, but so far there isn't a way to do that.

1 Like