XCode 9 - 导入#import 时出错 <objc/runtime.h> - 仅适用于模拟器

XCode 9 - Error while importing #import <objc/runtime.h> - for Simulator Only

我正在尝试导入#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

请注意:对于设备,编译成功。它仅为模拟器生成错误。自从我开始使用 XCode 9 后就发生了这种情况。对于 XCode 8,它工作正常。

看起来在 iOS 11 中,objc-runtime.h 已被删除。

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