Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLDB doesn't create convenience variable in Swift

In an objective-c project, this command works well. but in Swift,

(lldb) expr unsigned int $foo = 5

error: :1:4: error: consecutive statements on a line must be separated by ';'

int $foo = 5

 ^
 ;

How can I fix this?

like image 451
monadis Avatar asked Dec 08 '15 15:12

monadis


1 Answers

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. The swift equivalent is of your ObjC example is:

(lldb) expr var $foo : Int = 10

or since Swift does type inference, you can just say:

(lldb) expr var $foo = 10
like image 117
Jim Ingham Avatar answered Sep 18 '22 16:09

Jim Ingham