【问题标题】:XCode 9 - Error while importing #import <objc/runtime.h> - for Simulator OnlyXCode 9 - 导入 #import <objc/runtime.h> 时出错 - 仅适用于模拟器
【发布时间】:2017-10-24 03:02:38
【问题描述】:

我正在尝试导入#import,但出现以下错误:

必须先从模块“ObjectiveC.runtime”导入“objc_property_t”声明

代码如下:

#import <Foundation/Foundation.h>
#if TARGET_IPHONE_SIMULATOR
#import <objc/objc-runtime.h>
#else
#import <objc/runtime.h>
#import <objc/message.h>
#endif

请注意:对于Device,它已经编译成功。它只为模拟器生成错误。这发生在我开始使用 XCode 9 之后。对于 XCode 8,它运行良好。

【问题讨论】:

  • 您选择运行的部署目标或模拟器是否有影响?
  • 没有。这没有什么区别。同样的错误仍然存​​在。
  • 也可能是bug,试试11.1 beta SDK...

标签: ios objective-c xcode9 objective-c-runtime


【解决方案1】:

好像在 iOS 11 中,objc-runtime.h 已经被移除了。

您需要删除 if 宏或 import ,在其中。

【讨论】:

  • 删除宏
猜你喜欢
  • 1970-01-01
  • 2017-03-15
  • 2015-12-22
  • 2015-09-28
  • 2018-05-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多