Okay, I figured out what the problem was. Finally!
The key to figuring that out was to see how Xcode is actually calling clang
/swiftc
in the background, so you can call it yourself with exactly the same arguments and get the actual error message.
To get that information, you start Xcode in Terminal with sourcekit logging enabled
SOURCEKIT_LOGGING=3 /<path-to-xcode>/Xcode.app/Contents/MacOS/Xcode 2>xcode.txt
After you edited a source file, you can quit Xcode again and now the file xcode.txt
contains the sourcekit log. When you search for the file you just edited, you will stumble upon an entry that shows how the compiler was called in the background
key.compilerargs: [
"-x",
"objective-c",
"-ivfsoverlay",
:
All you need to do is converting that into a command line call by removing the comas and making all arguments a single line, then you can call the compiler yourself with the exact same arguments and it will tell you what the issue is.
More details about all this can be found here: https://stackoverflow.com/a/75605312/15809
In my case it turned out that a module has not been found by the compiler because the "Supported Destinations" (General tab for a framework target) were not correct. During a full build that played no role as the framework was still built for all the destinations and the linker would then find the module file in the build target location which is added to the search paths. But when creating the command line arguments for live issues, Xcode relies on this information correctly reflecting platform dependencies and if the current platform is not listed there, the module map of the framework is not added to the arguments and then the module is not found.
I think it's really a pity that Xcode is not showing these kind of errors by default somewhere in the UI. If you use Visual Studio Code, which uses the same mechanism as Xcode to lint source code and it runs into a similar problem, it will show you the actual error message in its error console and you will know at once what needs to be done to fix that.