Linking Error: Symbol Not Found

In building a recent project I encountered an error during the linking process. I want to point out the error message and show you how this simple error can be resolved. The reason for pointing out this error is that I have no idea why this error came about…more on that in a moment.

Start by looking at the figure below:

The problem we have here is that the class SomeClass is referenced inside the file PrivateMethods implementation file (the .o extension represents the compiled object of the PrivateMethod class).

For some reason SomeClass is not included in the target, that is, SomeClass is not included in the list of object files that make up the final executable. Upon giving this error some thought, the obvious place to look is at the list of files that make up the target. We can do this by looking at the Details tab as shown below:

Notice that SomeClass.m is not included in the target (see the rightmost column). Simply clicking to add this file to the target, rebuilding, and all is well.

The reason for presenting this relatively trivial problem, and the change to correct this, is that I did not (intentionally) remove this file from the target. The point being, even if you never mess with target files and/or related build configuration, you still may need to visit these options if you receive linking errors.

21 Comments

  1. Hi John,

    Not sure if I’m dealing with a linking error also–but I’m finding when I attempt to override a subclass, say ViewDidLoad, once I have de-commented the template for the subclass, I cannot recomment it (and therefore revert to not overriding the subclass) without incurring an error when I try to run the iPhone simulator. Have you encountered this problem?

    Any thoughts would be much appreciated!
    John

  2. John,

    Can you provide a short snippet of code to show what you are working on?

    Thanks

  3. Another thing that might cause this is if you are running the app in the simulator and you’ve forgotten to add the Core Graphics framework to your project.

  4. Thanks for posting this. Saved me a ton of effort.

  5. Many thanks! I have 2 targets and some files weren’t in my target.

  6. Just experienced a similar problem – but it was actually an xcode glitch. Compiled the project- and kept getting symbol not found. Looked on the file list and the file which contained the missing class wasn’t compiled (even when I manually did “compile”). The box was ticked, so what the heck.

    I just unticked the box, did a full project recompile, then ticked it again and it worked fine after. Silly xcode bug.

  7. John, i can’t thank you enough, the answer is so simple, yet without knowing about that tick box threre’s no way i’d have solved it. Thanks again.

Comments are closed.