29

I have a breakpoint set and want to print my UITextField's superview. I type po myTextField.superview but I receive the following error:

error: instance method 'undoManager' has incompatible result types in different translation units ('id' vs. 'NSUndoManager *')
note: instance method 'undoManager' also declared here
error: 1 errors parsing expression

What does this mean and how can I print my superview? I found a link that provides a janky workaround in code: http://openradar.io/15890965, but I would like a better solution.

Binarian
  • 12,296
  • 8
  • 53
  • 84
rizzes
  • 1,532
  • 20
  • 33
  • Same story here: I try `po tableView.gestureRecognizers` on a category of `UITableView`. – Drux Jul 29 '14 at 09:22
  • 3
    I have seen this error many times when trying to po frame, bounds, recursiveDescription, constraints, etc. (only built-in methods). Seems to be a crippling xcode/lldb bug. – kylefinn Aug 03 '14 at 22:34

5 Answers5

2

People of the world: I have an answer!

To dodge all UIKit errors: Before typing your po statement, type the line -- expr @import UIKit

If you want to turn this on for your app globally, then add the following breakpoint in your app delegate:

enter image description here

Thanks to Craig Hockenberry and Steve Streza for the update (found here).

rizzes
  • 1,532
  • 20
  • 33
  • This article tells you how to turn this on for all projects: http://merowing.info/2015/12/little-things-that-can-make-your-life-easier-in-2016/ – rizzes Jan 01 '16 at 21:10
1

The solution I use to prevent this error while debugging is to explicitly cast everything.

In your case I would do

po [(UITextField *)myTextField superView]
bhargavg
  • 1,383
  • 9
  • 12
  • From initial testing, this seems to work for me. However, the 2nd comment in the link above (http://openradar.io/15890965) claims that it happens for them, even when explicitly casting. Anyone else want to chime in? – rizzes Aug 12 '14 at 18:09
  • I tried explicitly casting and still get this error. e.g. po (NSString *)[((IBAdBannerView *)adView) recursiveDescription] – Kyle Robson Oct 07 '14 at 21:09
1

Do you have any custom accessor methods for 'myTextField'? I have seen this same issue a number of times and it is usually caused by the po trying to print a property for an object that gets initialized the first time its getter is called. For example, if I try to run 'po self.imageView.contentMode' on a UITableViewCell I get that same error. Try moving your breakpoint to a point in the code where you know that 'myTextField' has been fully initialized.

pbuchheit
  • 1,371
  • 1
  • 20
  • 47
0

Does myTextField really point to a UITextField? That's one reason this error will show up. For instance, the following code will compile, and if I set a breakpoint on the third line, I can enter po b.superview to reproduce the error you saw.

NSString *a = @"not a view";
UITextField *b = (UITextField *)a;
UIView *view = b.superview;

Try typing po [myTextField class] at your LLDB prompt to see if it's actually a UITextField. It could be another type of object, or nil.

0

I got this error in Xcode 5.1.1 and fixed it by quitting Xcode 5.1.1 and trying Xcode 6. Rebooting Xcode 5.1.1 for Xcode 5.1.1 may also work for some people.

Kyle Robson
  • 3,060
  • 24
  • 20
  • I have not yet found this error with Xcode 6, so Apple may have fixed it. It'll take some more time before we're sure though. – rizzes Oct 07 '14 at 22:25