本文介绍了如何使用Xcode 4.2区分多个目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了精简版的应用程序.现在,我想创建一个付费版本.因此,我复制了目标,更改了名称(因此,用该名称更改了plist和其他内容),现在我必须区分代码.我正在使用Xcode 4.2,并且在网络上看到必须创建预处理器标志.我的问题是Xcode 4.2中的此标志仅在项目的构建设置中,而不在目标的构建设置中.

I've developed a lite version of an app. Now I want to create a paid version.So I've duplicated the target, changed its name (so change plist and other stuff with that name) and now I have to differentiate in code. I'm using Xcode 4.2 and I see on the web that I have to create a preprocessor flag. My problem is that this flag in Xcode 4.2 is only in the project's build setting and not in the target's build setting.

我将需要能够执行以下操作:

I will need to be able to do something like this:

#ifdef paid
    ...
#else
    ...
#endif

推荐答案

使用预处理程序宏来执行此操作.转到目标->构建设置,然后选择所有配置"(这非常重要).接下来找到预处理器宏"字段.

Use preprocessor macros to do this.Go to Target -> Build Setting and choose "All configurations" (this is very important).Next find field "Preprocessor Macros".

在此字段中,将标记添加到ex中. PAID_VERSION.现在,您可以在代码中使用此标志:

In this field, add the flag in ex. PAID_VERSION. Now you can use this flag in code:

#ifdef PAID_VERSION
    NSLog(@"Paid version");
#else
    NSLog(@"Lite version");
#endif

这篇关于如何使用Xcode 4.2区分多个目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 05:48