Post

Replies

Boosts

Views

Activity

Reply to Error when debugging: Cannot create Swift scratch context
Trying to learn Swift and use debugging. On Xcode Version 12.3 (12C33) any time debugger is entered (on device simulator, or an actual device): Cannot create Swift scratch context (couldn't create a ClangImporter) (lldb)  po symbol in the (lldb) prompt doesn't work. And so no Swift objects or symbols are available; only an Objective C-type view of them. This is very annoying! and makes the debugger and debugging basically worthless in Xcode for Swift. On an M1 Mac mini. I completely uninstalled Xcode and deleted preferences and other developer directories from ~/Library. and re-installed Xcode (from app store). I scoured here and stack overflow for workarounds or diagnoses and nothing has worked. $ system_profiler SPSoftwareDataType Software: 		System Software Overview: 			System Version: macOS 11.1 (20C69) 			Kernel Version: Darwin 20.2.0 			Boot Volume: Macintosh HD 			Boot Mode: Normal 			Computer Name: * 			User Name: * 			Secure Virtual Memory: Enabled 			System Integrity Protection: Enabled 			Time since boot: 1:48 this works (swift from command line to run lldb from within) but I have no idea if it's useful info to help diagnose. ❯ swift Welcome to Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28). Type :help for assistance. 	1> : (lldb) expression -l swift -- import Foundation (lldb)
Jan ’21
Reply to Entering debugger: Cannot create Swift scratch context (couldn't create a ClangImporter)
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 haven't isolated the specific root cause of why this is, but that is the general case.
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21
Reply to Entering debugger: Cannot create Swift scratch context (couldn't create a ClangImporter)
I isolated it finally to a very very old (mid-1990s) csh-backed shell utility that was being used to add PATH components. I replaced its 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. put at end of path path+=/new/path put at front of path path=(/first/path $path)
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21