简体   繁体   English

LLDB不会在Swift中创建便利变量

[英]LLDB doesn't create convenience variable in Swift

In an objective-c project, this command works well. 在objective-c项目中,此命令运行良好。 but in Swift, 但在斯威夫特,

(lldb) expr unsigned int $foo = 5 (lldb)expr unsigned int $ foo = 5

error: :1:4: error: consecutive statements on a line must be separated by ';' 错误:: 1:4:错误:一行上的连续语句必须用';'分隔

int $foo = 5 int $ foo = 5

  ^ ; 

How can I fix this? 我怎样才能解决这个问题?

The expression parser uses the compiler's parser for the language of the current frame. 表达式解析器使用编译器的解析器作为当前帧的语言。 Presumably you are stopped in a Swift frame, so you have to use correct Swift syntax. 大概你是在Swift框架中停止的,所以你必须使用正确的Swift语法。 The swift equivalent is of your ObjC example is: 您的ObjC示例的快速等价物是:

(lldb) expr var $foo : Int = 10

or since Swift does type inference, you can just say: 或者既然Swift做了类型推断,你可以说:

(lldb) expr var $foo = 10

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM