Can Poyrazoğlu
Can Poyrazoğlu

Reputation: 34780

lldb error: property not found on object of type

I am trying to debug my iOS app using lldb and I'm getting really weird errors on debug.

A few lines before my breakpoint, I've got:

CGRect frame = view.frame;

Which I can access with no problems with print frame command in lldb. However, when I try to access the frame again in lldb, I type print view.frame and get the following error:

error: property 'frame' not found on object of type 'UIView *'

This doesn't make sense as I can verify the view is a UIView* instance and has a valid property called frame by typing po view and getting correct results:

(UIView *) $4 = 0x1e199bf0 <MyAppCustomView: 0x1e199bf0; frame = (3398 3396; 204 208); layer = <CALayer: 0x1e199ce0>>

This particular lldb error happens to me a lot, and I couldn't find the cause of this error. Someone suggested at Property 'count' not found on object of type 'NSMutableArray *' PO command in lldb that one could use gdb as (gdb) p view.frame but I'm getting error: '(gdb)' is not a valid command. and I highly suspect that a gdb command would "work?" inside another debugger anyway.

Any suggestions or workarounds for this bug which occurs randomly?

Upvotes: 23

Views: 13961

Answers (3)

Nate Chandler
Nate Chandler

Reputation: 4553

Dot notation for message sending is not supported in lldb when using Objective-C. Use bracket notation and cast the result to CGRect:

p (CGRect)[view frame]

Upvotes: 60

Andrew
Andrew

Reputation: 7710

I had to disable (uncheck) Thread Sanitizer in Xcode > Product > Scheme > Edit Scheme > Run > Diagnostics. With Thread Sanitizer enabled I wasn't able to access many NSView properties (e.g. bounds, frame) through LLDB.

Upvotes: 1

ssdscott
ssdscott

Reputation: 693

Just in case the above doesn't work (which it didn't for me, looking for the frame for a variable cell, class derived from UITableViewCell): forcing the extra parentheses seemed to help lldb's little ditty brain:

p ((CGRect)[cell frame])

presto magico:

(CGRect) $5 = origin=(x=0, y=0) size=(width=320, height=44)

Upvotes: 4

Related Questions