问题描述
为什么编译一个ApplicationTests单元测试包时这个代码不工作?
#if TARGET_OS_IPHONE
#导入< Foundation / Foundation.h>
#import< UIKit / UIKit.h>
#else
#import< Cocoa / Cocoa.h>
#endif
我的一个依赖有这个检查,并且在我的主应用程序中编译得很好但它会在编译我的ApplicationTests包时尝试加载< Cocoa / Cocoa.h>
。这可能只是我对XCode的理解不够,但是当我的测试包不能构建时,我会感到紧张。任何建议?
我有类似的问题: TARGET_OS_IPHONE
isn'在构建静态库时定义。我的解决方案是将 -DTARGET_OS_IPHONE
添加到目标构建选项的其他C标记
部分。 / p>
Why doesn't this code work when compiling an ApplicationTests unit test bundle?
#if TARGET_OS_IPHONE
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
One of my dependencies has this check and compiles just fine in my main application bundles, but it tries to load <Cocoa/Cocoa.h>
when compiling my ApplicationTests bundle. It's probably just my lack of understanding of XCode, but I get nervous when my test bundles don't build. Any suggestions?
I had a similar problem: TARGET_OS_IPHONE
isn't defined when building a static library. My solution was to add "-DTARGET_OS_IPHONE
" to the "Other C Flags
" section of the target build options.
这篇关于TARGET_OS_IPHONE和ApplicationTests的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!