_OBJC_CLASS_$_ errors 错误解决办法

先给大家看一下原作者的

http://blog.sina.com.cn/s/blog_4fcd1ea30100zw6i.html


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.

view plain copy to clipboard print ?
  1.  "_OBJC_CLASS_$_NSManagedObjectModel", referenced from:  
  2.       objc-class-ref-to-NSManagedObjectModel in AuditorAppDelegate.o  
  3.   "_OBJC_CLASS_$_NSEntityDescription", referenced from:  
  4.       objc-class-ref-to-NSEntityDescription in CoreDataAccess.o  
  5.   "_OBJC_CLASS_$_NSFetchRequest", referenced from:  
  6.       objc-class-ref-to-NSFetchRequest in CoreDataAccess.o  
  7.   "_OBJC_CLASS_$_NSManagedObjectContext", referenced from:  
  8.       objc-class-ref-to-NSManagedObjectContext in AuditorAppDelegate.o  
  9.   "_OBJC_CLASS_$_NSPersistentStoreCoordinator", referenced from:  
  10.       objc-class-ref-to-NSPersistentStoreCoordinator in AuditorAppDelegate.o  
  11.   "_NSSQLiteStoreType", referenced from:  
  12.       _NSSQLiteStoreType$non_lazy_ptr in AuditorAppDelegate.o  
  13.      (maybe you meant: _NSSQLiteStoreType$non_lazy_ptr)  
  14. ld: symbol(s) not found  
  15. collect2: ld returned 1 exit status  

2. 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


看完之后我就明白原来是这样子,就是找到$后面那个.m文件,点中之后在右边的show the file inspector栏目中的target membership中找到目标
_OBJC_CLASS_$_ errors 错误解决办法_第1张图片

你可能感兴趣的:(ios)