Missing from the target

It's not unusal to see the following error when attempting to use a new framework or class:

_OBJC_CLASS_$_'XYZ'

There are mainly two reasons why this error occurs.

  1. Forgotten to include a framework that you are attempting to use.
  2. A class's .m file isn't included in the Target.

See below for more information on both these possible causes.

Missing framework

Lets use the example error of _OBJC_CLASS_$_CoreData. If when adding Core Data to your project manually, you receive a similar set of errors as below it is because you have forgotten to include the Core Data framework.

"_OBJC_CLASS_$_NSManagedObjectModel", referenced from:
      objc-class-ref-to-NSManagedObjectModel in AuditorAppDelegate.o
  "_OBJC_CLASS_$_NSEntityDescription", referenced from:
      objc-class-ref-to-NSEntityDescription in CoreDataAccess.o
  "_OBJC_CLASS_$_NSFetchRequest", referenced from:
      objc-class-ref-to-NSFetchRequest in CoreDataAccess.o
  "_OBJC_CLASS_$_NSManagedObjectContext", referenced from:
      objc-class-ref-to-NSManagedObjectContext in AuditorAppDelegate.o
  "_OBJC_CLASS_$_NSPersistentStoreCoordinator", referenced from:
      objc-class-ref-to-NSPersistentStoreCoordinator in AuditorAppDelegate.o
  "_NSSQLiteStoreType", referenced from:
      _NSSQLiteStoreType$non_lazy_ptr in AuditorAppDelegate.o
     (maybe you meant: _NSSQLiteStoreType$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status

To solve this you just need to added the missing framework.

Missing class

If you get a _OBJC_CLASS_$_'XYZ' error it is most likely because .m file is not being included as part of your target.

To add it to a target in Xcode 3:

  • Open .m file
  • If top section is closed open it - this section should contain "yourclassname".m (click on image below)
  • Tick the checkbox at end of this row
  • Rebuild your project and enjoy

To reinstate it as a target in Xcode 4:

  • Select project in "Project navigation" side menu
  • Select interested Target
  • Select "Build Phases" tab
  • Expand "Compile Sources
  • Scroll down to the bottom of the expanded view and click on the "+" button
  • In the pop up window that appears navigate to interested file and double click (or highlight and press add button)
  • Rebuild your project and enjoy