我有一个在 iOS 和 OS X 目标之间共享代码的项目。 iOS 目标编译正常。但是 OS X 目标以某种方式包含一个特定的静态库类,该类导入 UIKit 框架,并且出于明显的原因抛出错误。我不需要在 OS X 目标中包含该类别。我已从文件检查器中该文件的目标成员选项卡中取消选择 OS X 目标。作为 OS X 开发的新手,我不知道在为 OSX 编译时在哪里查看不包含该类。我可能做错了什么?
最佳答案
标题应该是这样的:
#if TARGET_OS_IPHONE
// iOS code
#import <UIKit/UIKit.h>
#endif
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
在 XCode
中:
- Select the Target you wish to exclude the class or library from
- Click on
Build Phases
>Compile Sources
orLink Binary With Libraries
- Select the class or library to exclude and hit
-
该类不应再使用该目标进行编译。
关于ios - iOS 和 OS X 目标的通用预编译 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30203558/