Weird error message in Xcode 4.3 with LLDB

2020-01-29 11:13发布

问题:

I am currently writing an iOS app with Xcode 4.3.2. In most parts of my code, debugging with LLDB works just fine. However at some point I am getting a strange message while stepping through my code. When I hover over an iVar, it says

Error [IRForTarget]: Couldn't find Objective-C indirect ivar symbol OBJC_IVAR_$_MyFancyClass.iVar

instead of showing me the value. However, in the Variables View, I can see it just fine. Until I'm selecting Print Description of ... that is, because then, Xcode crashes... When I use GDB, the hovering works but the type and values of the variable are wrong.

I recon that there is something wrong with my code which in turn causes the debuggers to fail. However, the code runs fine. I'd love to provide some samplecode but the class is rather long and I can't pinpoint the exact location of my screwup. So has anybody encountered a similar behavior?

UPDATE: Actually, it seems as if this happens everywhere in my code, not just in some specific files. If it helps, while LLDB show the above message, GDB always shows an object of the Class that is owning the iVar, instead of the iVar itself. It looks as if there is something wrong with the memory management. For example, if I say something like

[notificationCenter addObserver:self selector:@selector(foo) name:bar object:objA];

the selector is invoked even when I have

[notificationCenter postNotificationName:bar object:objB];

回答1:

The cause of this error are incorrect build settings, as indicated by the discussion in the question post comments. This can be fixed by setting "Deployment Postprocessing" back to NO for Debug-Mode (the default value).



回答2:

Make sure MyFancyClass.m is added to your Target



回答3:

Your selector that the nsnotification is being sent to needs to have one (and only one) argument, which is an NSNotification. So when you do this:

[notificationCenter addObserver:self selector:@selector(foo) name:bar object:objA];

-(void)foo
{

}

...you need to be doing this: [notificationCenter addObserver:self selector:@selector(foo:) name:bar object:objA];

-(void)foo:(NSNotification *)notification
{

}

Notice the colon in the selector for the notificationCenter, and the argument for foo.