来自一个代码库的多个应用程序 - Xcode 中的多个项目或目标?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17232279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:31:59  来源:igfitidea点击:

Multiple apps from one code base - multiple projects or targets in Xcode?

iosxcode

提问by Miriam

I am developing an iOS app. Right now it is one app and two targets (app and tests).

我正在开发一个 iOS 应用程序。现在它是一个应用程序和两个目标(应用程序和测试)。

Getting closer to publishing I want to split this app into three apps with lots of shared code and shared tests. (Think of free version and full version for App Store and prototyping app that will not be published).

离发布越来越近了,我想将此应用程序拆分为三个应用程序,其中包含大量共享代码和共享测试。(想想不会发布的 App Store 和原型应用程序的免费版和完整版)。

Would you set up multiple projects in Xcode (1 library project and 3 app projects) or keep all in one project and only set up multiple targets?

您会在 Xcode 中设置多个项目(1 个库项目和 3 个应用程序项目)还是将所有项目都保存在一个项目中并且只设置多个目标?

回答by Mundi

I think you have at least 3 options here:

我认为您在这里至少有 3 个选择:

  1. Separate projects. It is more difficult to share code across projects, but with Xcode workspaces this is quite feasible. If you have a lot of customization for each project, this might make sense.

  2. Same project, more targets. This is the usual way this is done. It is very easy because you have a very neat overview of what files go into which target. If you have around, say, a dozen or so targets, it is really quite easy to handle.

  3. Separate git branches. I have worked with this in the past. The differences between the apps (Info.plist, configuration files, data files) are just swapped in the corresponding git branch. This is practical if you have a lot of data and don't need to have all of it available at all times. However, the complexity of git is considerable if you are not familiar with it. You can create git submodules to change the shared code parts in one go.

  1. 单独的项目。跨项目共享代码更加困难,但对于 Xcode 工作区,这是非常可行的。如果您对每个项目进行了大量自定义,这可能是有意义的。

  2. 同样的项目,更多的目标。这是通常的做法。这很容易,因为您可以非常清楚地了解哪些文件进入哪个目标。如果您有大约十几个目标,那么处理起来真的很容易。

  3. 分开 git 分支。我过去曾与此合作过。应用程序之间的差异(Info.plist、配置文件、数据文件)只是在相应的 git 分支中交换。如果您有大量数据并且不需要所有时间都可用,这很实用。但是,如果您不熟悉 git,它的复杂性是相当可观的。您可以创建 git 子模块来一次性更改共享代码部分。