TARGET_OS_IPHONE和ApplicationTests [英] TARGET_OS_IPHONE and ApplicationTests

查看:72
本文介绍了TARGET_OS_IPHONE和ApplicationTests的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么编译一个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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆