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

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

问题描述

我为我的应用程序设置了两个目标(精简版和专业版),我想在每个目标的代码中集成一些细微差别(例如,专业版不会显示任何 iAd 横幅).

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).

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

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

推荐答案

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

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.

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

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

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

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