从单个 Xcode 项目高效构建两个版本的 Iphone 应用程序? [英] Efficiently build two versions of an Iphone app from a single Xcode project?

查看:27
本文介绍了从单个 Xcode 项目高效构建两个版本的 Iphone 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的应用制作付费和免费版本.我想对事物进行结构化,以便我可以构建一个版本或另一个版本,并且更改尽可能少.就源代码而言,这可以通过在某处设置一个 BOOL 常量 isFreeVersion 并根据需要引用它来轻松实现.

I want to make paid and free versions of my app. I want to structure things so that I can build one version or the other with as few changes as possible. As far as the source code is concerned, this is easily accomplished by having a BOOL constant isFreeVersion somewhere, and referring to it as needed.

但是我应该如何设置其他一切?显然,App ID 必须更改,而这反过来又需要更改 XCode 中的一些构建设置.将其保持在最低限度的最佳方法是什么?

But how should I set everything else up? Obviously the App ID will have to change, and this will in turn entail changing some build settings in XCode. What is the best way to keep that to a minimum?

推荐答案

您可以使用预处理器标志(在您的 Xcode 构建设置中)在两者之间切换.可以使用简单的预处理器指令(例如#if IS_FREE_VERSION ... #endif)以类似于 if 语句的方式在您的源代码中使用该标志.这将帮助您避免构建脚本.

You could use a preprocessor flag (in your Xcode build settings) to switch between the two. The flag can be used across your source code using simple preprocessor directives (e.g. #if IS_FREE_VERSION ... #endif) in a manner similar to an if statement. This will help you avoid build scripts.

这种方法的缺点是默认情况下,每次构建时,最后一个构建产品都会被覆盖.

The disadvantage of this approach is that by default each time you build, the last build product gets overwritten.

这篇关于从单个 Xcode 项目高效构建两个版本的 Iphone 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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