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

  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 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中找到目标


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值