iosswiftxcodelldb

lldb error: couldn't IRGen expression: Clang importer error


I have an iOS project written in swift running on the simulator. (xcode 15.2, SDK 17.2) When trying to print an expression in the lldb console, I get the following error:

couldn't IRGen expression: Clang importer error

This is followed by a changing cast of what look like clang errors, sometimes about undefined variables in system headers, or missing symbols.

This is different than other IRGen errors discussed on stackoverflow, and the solutions there didn't work. I have of course deleted my derived data.


Solution

  • I resolved the issue by clearing the clang module cache found in /var/folders/[short directory name]/[long alphanumeric name]/C/clang/ModuleCache. Jim Ingham's comment provided the necessary clue. There must've been something wrong with the modules in that cache.