Strange debugging problem
Recently I had to take over a project a ex-collegue had nearly finished before he left. During debugging I came across a strange problem. The debugger only stopped at some of my breakpoints. In some classes the breakpoints have been useless. First I thought that the code at these breakpoints did not get executed. But when I added NSLog statements in the line before or after the breakpoint the log worked.
It took a while until I figured out that the implementation file was not added to the target I was debugging. But why did this code then even got executed (as I knew because of the NSLog statements)? And why did it even compile.
After I added the file to the target I got the compiler error
`duplicate symbol _OBJC_IVAR_$...`.
What the...?!?
A little internet search helped me to find the underlying problem. The ex-collegue had five times imported the implementation file instead of the interface file. So in five classes there where
[code language="objc"]
#import "MyAwesomeClasse.m"
[/code]
instead of
[code language="objc"]
#import "MyAwesomeClasse.h"
[/code]
In total it took me nearly two hours to find and fix the bug. I hope this post will save you from wasting this time.