如何在Xcode 4中定义预处理器宏? [英] How do I define preprocessor macros in Xcode 4?

查看:85
本文介绍了如何在Xcode 4中定义预处理器宏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的应用设置了两个目标(精简版和专业版),并且我希望在每个代码中集成一些细微的差异(例如,专业版不会显示任何iAd标语). /p>

我一直在环顾四周,我发现最简单的方法是使用预处理器宏.我面临的问题是如何在Xcode 4中设置它们.我想在一个目标&中设置一个名为"PRO_VERSION"的宏.另一个是"LITE_VERSION".

下面是我打算如何使用它们的一个示例:

#ifdef PRO_VERSION
    // Hide ad banners
#else
    // Show ad banners
#endif

解决方案

您需要更改的构建设置称为预处理器宏",可以在项目设置"窗格的构建设置"选项卡中找到(使用搜索框找到它).在项目设置"窗格的左侧依次选择每个目标,然后修改预处理器宏"设置.

该设置被指定为以空格分隔的预处理器宏列表,格式为'foo'或'foo = bar'.

I have two targets set up for my app (a lite version and a pro version) and I want to integrate some subtle differences in the code for each of them (e.g. the pro version will not show any iAd banners).

I have been looking around and I see the easiest way to do this is through the use of preprocessor macros. The issue I'm facing is how to set them up in Xcode 4. I want to set up a macro called 'PRO_VERSION' in one target & 'LITE_VERSION' in the other.

Below is an example of how I intend to use them:

#ifdef PRO_VERSION
    // Hide ad banners
#else
    // Show ad banners
#endif

解决方案

The build setting you need to change is called 'Preprocessor Macros' and it can be found in the 'Build Settings' tab of the Project Settings pane (use the search box to find it). Select each target in turn in the left-hand side of the Project Settings pane then modify the Preprocessor Macros setting.

The setting is specified as a space-separated list of preprocessor macros in the form 'foo' or 'foo=bar'.

这篇关于如何在Xcode 4中定义预处理器宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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