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.