2

I noticed the following behavior when using OCMock, and after poking around I discovered it is an issue with how the Xcode debugger handles methods that are not implemented. Here's an example:

@implementation ForwardingClass

- (id)init {
    self = [super init];
    self.delegate = [[DelegateClass alloc] init];
    return self;
}

- (void)forwardInvocation:(NSInvocation *)anInvocation {
    [anInvocation invokeWithTarget:self.delegate];
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel {
    return [self.delegate methodSignatureForSelector:sel];
}

- (BOOL)respondsToSelector:(SEL)aSelector {
    return YES;
}

@end



@implementation DelegateClass

- (void)forwardedMethod {
    NSLog(@"got it!");
}

@end

Now we can call it:

ForwardingClass *forwardingClass = [[ForwardingClass alloc] init];

// Xcode will not step into this method
[(id)forwardingClass forwardedMethod];

Xcode will not step into the forwardedMethod. Even worse, if I set a breakpoint in forwardInvocation it won't break there. The net effect is that you can't step into any object that has been partially mocked by OCMock.

Any ideas how to fix this?

Is it a bug (or unintended "feature") in Xcode? I've tried this on both Xcode 6 and Xcode 7 beta 4.

David
  • 2,429
  • 24
  • 15
  • 1
    So, you are saying that if you set a breakpoint on the line `NSLog(@"got it!");` the debugger will not stop? That doesn't seem right. I have seen issues with the debugger sending methods requesting descriptions from the object, that then retriggered `forwardInvocation:` making debugging difficult, but I can't remember seeing the problem that I think you're describing. – Erik Doernenburg Aug 11 '15 at 09:39

0 Answers0