_OBJC_CLASS_$_ errors

There are mainly two reasons why this occurs. The first being that you have forgotten to include a framework that you are attempting to use, the second being that a class .m file has been unticked as a Target. See below for more information on both these possible causes.

  1. Lets use the example error of _OBJC_CLASS_$_CoreData. If when adding CoreData access to your project manually, you receive a similar set of errors as below it is because you have forgotten to include the CoreData 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
  1. If you get _OBJC_CLASS_$_"yourclassname" 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