When I use LLDB on a Swift application in Xcode (e.g. by setting a breakpoint), I can call
settings set target.language swift
to have LLDB understand Swift code in commands like expression
(and therefore po
and print
).
When I run lldb
from the command line and try setting the target language as above, I get the error:
error: invalid language type 'swift', valid values are:
c89
c
c++
c99
objective-c
objective-c++
c++03
c++11
c11
c++14
Is anyone else having this same problem? How could I fix this?
I'm running macOS 10.15.7
You probably have a brew or llvm.org install of the clang toolchain, including lldb, in front of /usr/bin/lldb on your path. The clang toolchains don't include the swift compiler, or a swift-enabled lldb.
Running the lldb
will find the first lldb installed on your path, which is probably a clang one from home-brew or llvm.org.
Running the command xcrun lldb
will always run the one from your installed Xcode. Also, you can tell by the result of the version command in lldb. The swift enabled versions will print the Apple Swift version along with the lldb version. The clang ones won't.