[每当我以快速模式运行LLDB表达式时,都会出现以下错误。
无法创建Swift暂存上下文(无法加载Swiftstdlib)无法创建Swift暂存上下文(无法加载Swiftstdlib)堆栈转储:0.程序参数:/Applications/Xcode.app/Contents/Developer/usr/bin/lldb [1] 77539分割错误lldb
我尝试导入什么都没有关系。
~ ❯❯❯ lldb
(lldb) expression -l swift -- import AppKit
Cannot create Swift scratch context (couldn't load the Swift stdlib)Cannot create Swift scratch context (couldn't load the Swift stdlib)Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
[1] 6665 segmentation fault lldb
~ ❯❯❯ lldb ✘ 139
(lldb) expression -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)Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
[1] 7122 segmentation fault lldb
~ ❯❯❯ lldb ✘ 139
(lldb) expression -l swift -- import UIKit
Cannot create Swift scratch context (couldn't load the Swift stdlib)Cannot create Swift scratch context (couldn't load the Swift stdlib)Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
[1] 7225 segmentation fault lldb
~ ❯❯❯ ✘ 139
有趣的是,在Xcode中使用LLDB时,命令的工作原理完全相同。
以下对话在我的终端中有效:
themini:~ mattneubelcap$ 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) expr -lSwift -- import Foundation
(lldb) expr -lSwift -- "howdy" as NSString
第二条命令的成功证明Foundation已成功导入。如果不是,我们会收到error: use of undeclared type 'NSString'
。
注意-l
和Swift
之间没有空格。我不知道为什么“完全相同的命令”在Xcode中使用LLDB(即在空格处)起作用。当然,如果您键入help expr
,您会得到-l Swift
应该有效的印象。尽管如此,实验表明,就像大多数命令行命令一样,在终端中它必须为-lSwift
(无空格)或--language Swift
(空格)。是Xcode LLDB更宽容还是遵循不同的语法规则(使用不同的解析器)?我不知道。