_OBJC_CLASS_$_ errors 错误解决办法

本文介绍了两种常见的Objective-C编译错误原因及解决方案:一是忘记包含所需的框架;二是.m文件未被设置为目标文件。文中提供了具体步骤来解决这两类问题。

先给大家看一下原作者的

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


以上结果运行后我的代码 编辑器 Tab''"",.:=()[]\{}<>/;?$ 输入 运行 75 __all__ = ['set_password', 'get_password'] 76 """ 77 with open('keychain_bridge.py', 'w') as f: 78 f.write(bridge_code) 79 print("✅ 已创建keychain桥接模块") 80 def repair_workflow(): 81 print("=== 开始诊断 ===") 82 if diagnose_keychain_error(): 83 return 84 85 print("\n=== 修复环境路径 ===") 86 reset_pythonista_path() 87 88 if not diagnose_keychain_error(): 89 print("\n=== 创建桥接模块 ===") 90 create_keychain_bridge() 91 print("✅ 请使用 'import keychain_bridge' 替代 'import keychain'") 92 93 print("\n=== 测试Keychain访问 ===") 94 safe_keychain_usage() 95 if __name__ == "__main__": 96 repair_workflow() 97 # 禁止访问的危险类列表 98 DANGEROUS_CLASSES = ['UIAccelerometer', 'UITelephony', 'UIDevice'] 99 def validate_class(cls_name): 100 if cls_name in DANGEROUS_CLASSES: 101 raise SecurityError(f"禁止访问私有API: {cls_name}") 102 # 禁止访问的危险类列表 103 DANGEROUS_CLASSES = ['UIAccelerometer', 'UITelephony', 'UIDevice'] 104 def validate_class(cls_name): 105 if cls_name in DANGEROUS_CLASSES: 106 raise SecurityError(f"禁止访问私有API: {cls_name}") 107 ​ 你好,世界 === 开始诊断 === ❌ 未找到keychain模块 ⚠️ 当前非Pythonista环境,iOS沙盒限制无法使用keychain ​ === 修复环境路径 === 🛠️ 已添加路径: /private/var/mobile/Containers/Shared/AppGroup/Pythonista3/Documents 🛠️ 已添加路径: /private/var/mobile/Containers/Shared/AppGroup/Pythonista3/site-packages 🛠️ 已添加路径: /private/var/containers/Bundle/Application/Pythonista3.app/Frameworks 🛠️ 已重置PYTHONPATH环境变量 ❌ 未找到keychain模块 ⚠️ 当前非Pythonista环境,iOS沙盒限制无法使用keychain ​ === 创建桥接模块 === ✅ 已创建keychain桥接模块 ✅ 请使用 'import keychain_bridge' 替代 'import keychain' ​ === 测试Keychain访问 === Traceback (most recent call last): File ".code.tio", line 96, in <module> repair_workflow() File ".code.tio", line 94, in repair_workflow safe_keychain_usage() NameError: name 'safe_keychain_usage' is not defined。如何通过未越狱苹果手机,仅用python实现以上操作,不借助任何外物。给我一串完整的代码
最新发布
08-22
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值