Group Group Group Group Group Group Group Group Group

Failed debugging in Swift

(lldb) ex -l swift -- import Foundation
Shared Swift state for Xcode could not be initialized.
The REPL and expressions are unavailable.

in Chapter 1 “Swift vs Objective-C debugging”

ex -l swift – import Foundation

Cannot create Swift scratch context (couldn’t load the Swift stdlib)Cannot create Swift scratch context (couldn’t load the Swift stdlib) Shared Swift state for Xcode could not be initialized.

The REPL and expressions are unavailable.

Is what I see running the latest versions of OS X and Xcode. The latest version of OS X is running zshell.

running ‘system_profiler SPSoftwareDataType’ returns:

dev@dev-mbp ~ % system_profiler SPSoftwareDataType
Software:

System Software Overview:

  System Version: macOS 10.15.2 (19C57)
  Kernel Version: Darwin 19.2.0
  Boot Volume: Macintosh HD
  Boot Mode: Normal
  Computer Name: dev_mbp
  User Name: dev
  Secure Virtual Memory: Enabled
  System Integrity Protection: Disabled
  Time since boot: 18:47

The version of Xcode I’m using is:

Version 11.3 (11C29)

@cupofjoe & @justinlearnios Did you find a solution to this issue?

The import works when you start the LLDB from the swift REPL

~ ❯❯❯ swift
Welcome to Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15).
Type :help for assistance.
  1> :
(lldb) expression -l swift -- import Foundation
(lldb)

@lolgrep Can you please help with this when you get a chance? Thank you - much appreciated! :]

If I start the LLDB form the swift REPL, then I can not successfully follow previous instructions, maybe previous instructions depends on Objective-C?
Is there any better solution can successfully follow this chapters’ instructions.

Which instructions are you getting stuck at because I can import Objective-C Foundation both outside and inside the Swift REPL

 ❯ lldb                                                                                                                                                                                    [16:06:28]
(lldb) e @import Foundation
(lldb) ^D
>>> elapsed time 3m19s

 ❯ swift                                                                                                                                                                                   [16:09:51]
Welcome to Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51).
Type :help for assistance.
  1> :
(lldb) e @import Foundation
(lldb)

I’m having the same issue, if I use the suggestion above
e @import Foundation it will not throw an error importing Foundation and Appkit. When I attempt to run the next command though
ex -l swift -o -- unsafeBitCast(0x0000000115023e00, to: NSView.self) I get a different error.

Cannot create Swift scratch context (couldn't load the Swift stdlib)Cannot create Swift scratch context (couldn't load the Swift stdlib)Shared Swift state for Xcode could not be initialized.
The REPL and expressions are unavailable.

Funny enough, I have a lot of trouble at work with the scratch context giving my trouble all the time on a very large mixed objc/swift project…

@lolgrep Can you please help with this when you get a chance? Thank you - much appreciated! :]