如何在不复制Xcode 4项目的情况下从付费版本构建免费版本? [英] How to build a free version from a paid version without duplicating the Xcode 4 project?

查看:102
本文介绍了如何在不复制Xcode 4项目的情况下从付费版本构建免费版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说有传言说可以通过使用目标和条件编译指令(例如

I've heard rumors that it is possible to build different variations of an app without duplicating Xcode projects, by using targets and conditional compilation instructions like

IF !FREE_VERSION 
[self loadGreatFeature];
ELSE
[self loadBoringFeature];

所以:


  • 如何设置Xcode 4以区分建立/存档项目的免费或付费版本?

  • How to set Xcode 4 up to be able to distinguish between building / archiving a free or paid version of the project?

如何告诉Xcode 4在付费版本中包含一组图像和其他资源,但不包含在免费版本中(反之亦然)?

How to tell Xcode 4 to include a certain set of images and other resources in the paid version, but not in the free version (and vice versa)?

如何告诉Xcode 4构建免费的OR付费版本? (不想一直构建它们,因为这会降低开发速度)

How to tell Xcode 4 to build the free OR paid version? (don't want to build both of them all the time as this would slow development down)

这种方法的注意事项是什么?

What are the caveats of this approach?

我知道重复Xcode项目有什么警告:一旦我修复了任何一个版本中的错误,我必须做同样的事情在另一个。同样可以进行改进和修改。

I do know what's the caveat of duplicating the Xcode project: Once I fix a bug in either version, I must do the same thing in the other. Same goes for making improvements and modifications.

推荐答案

在Xcode中打开项目并选择中的顶级项目Project Navigator 。您应该看到项目的目标列表。

Open your project in Xcode and select the top-level item in the Project Navigator. You should see the list of targets for your project.

为应用的免费版本创建新目标。一种简单的方法是按住Control键并单击与您想要的类似的当前目标并复制它。

Create a new target for the free version of your app. An easy way to do this is to control-click a current target that's similar to what you want and duplicate it.

选择新目标。在构建阶段选项卡中,您可以控制将哪些源文件构建为此目标的一部分以及为其复制哪些资源。在构建设置标签中搜索预处理器宏,并为所有构建配置添加新的,例如MYAPPLITE = 1。然后,您可以在代码中使用以下内容进行条件编译:

Select your new target. In the Build Phases tab you can control which source files will be built as part of this target and which resources are copied for it. In the Build Settings tab search for Preprocessor Macros and add a new one, for example MYAPPLITE=1, for all build configurations. You can then do conditional compilation in your code with something like:

#ifdef MYAPPLITE
    [self loadBoringFeature];
#else
    [self loadGreatFeature];
#endif

最后,选择编辑方案... 从产品菜单中。应该已经为您的新目标创建了一个新方案。如果需要,您可以在管理方案表中重命名。您可以在此处控制构建,运行,存档等新目标的特定设置。

Finally, select Edit Scheme... from the Product menu. A new scheme should already have been created for your new target. You can rename it in the Manage Schemes sheet if you want. You can control specific settings for building, running, archiving etc. the new target here.

要在构建免费版本或付费版本之间切换,只需更改活动方案即可。

To switch between building the free version or the paid version you just change the active scheme.

唯一真正需要注意的是,您需要保持新目标的设置是最新的。

The only real caveat is that you need to keep the settings for your new target up to date.

这篇关于如何在不复制Xcode 4项目的情况下从付费版本构建免费版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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