Cannot create Swift scratch context (couldn't create a ClangImporter)

I'm getting the error "Cannot create Swift scratch context (couldn't create a ClangImporter)" when running a Swift project in XCode 12.3 on Catalina when I try to use the debugger. There is a resolution of this problem described at https://forums.raywenderlich.com/t/entering-debugger-in-swift-project-couldnt-create-a-clangimporter/130829 but I don't understand the fix of "removing zsh customisations in dotfiles". Can anyone explain what the files to change are and how they have to be changed? (I'm new to Mac development)

This problem often recurs, even with a new account and using the bash shell. Closing and re-opening Xcode seems to fix it.

I haven’t yet watched this, but I suspect that WWDC 2022 Session 110370 Debug Swift debugging with LLDB will be very helpful here.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I managed to get similar problem fixed, in my case the root cause was a library that was distributed in binary form and had somehow managed to put extra framework searchpaths in the library configuration. The search paths were relative to the developers computer home folder so they did not work properly. There were also some extra flags that were used for their internal debugging.

I managed to find the root cause by using swift-healthcheck on the debugger and comparing it to a version that did not have this problem.

There is not too much information about the swift-healthcheck available currently, but you can just type it in the debugger and see the output. Debug Swift with LLDB (WWDC 2022) session had some information.

Cannot create Swift scratch context (couldn't create a ClangImporter)
 
 
Q