从单个 Xcode 项目高效构建两个版本的 Iphone 应用程序?
我想制作我的应用程序的付费和免费版本。我想要构建一些东西,以便我可以用尽可能少的更改来构建一个版本或另一个版本。就源代码而言,这可以通过在某处使用 BOOL 常量 isFreeVersion 并根据需要引用它来轻松完成。
但我应该如何设置其他一切呢?显然,App ID 必须更改,而这又需要更改 XCode 中的一些构建设置。将其保持在最低限度的最佳方法是什么?
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.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用预处理器标志(在 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.
就一般版本控制而言,我不推荐 使用分支除非构建两个版本的影响意味着两组源代码之间发生重要的代码更改。
如果您只能拥有一组源(使用
BOOL
常量),则意味着其余部分必须通过构建脚本进行管理,该脚本将:In term of version control in general, I wouldn't recommend using branches unless the impact of building two versions means important code changes between the two set of sources.
If you can have only one set of sources (with your
BOOL
constants), that means the rest must be managed through building script, which would: