Entering debugger in Swift project: couldn't create a ClangImporter

For https://www.raywenderlich.com/4681-beginning-ios-debugging/lessons/4

Am getting the following in Xcode when breakpoint hit:

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

Am seeing this same error mesasge in any Swift project I try. Debugger is unusable for inspecting Swift state, as a result.

Screen Shot 2021-01-22 at 12.46.15 PM

After hours and days of attempting to narrow down the cause, after I remove all zsh customizations (in dotfiles) on an account, the LLDB Swift debugging finally works again. Swift structure state can be inspected, and po symbol works.

(the lldb startup error Cannot create Swift scratch context (couldn't create a ClangImporter) is gone too)

I isolated it finally to a very very old (mid-1990s) csh-backed shell utility that was being used to add PATH components in zshenv.

I replaced utility’s functionality with ZSH’s built-in way to do this, and everything seems to be working as it should be.

It’s not completely clear what exactly was breaking the LLDB invocation by Xcode, but I am fine with modified way.

This topic was automatically closed after 166 days. New replies are no longer allowed.