如何使用可扩展和干净的模式制作相同的 iOS Swift 应用程序,而代码和资产只有一些差异

如何使用可扩展和干净的模式制作相同的 iOS Swift 应用程序,而代码和资产只有一些差异

问题描述:

我有这个需求.

我开发了一个应用程序,我想复制它.我可以复制和粘贴该项目,但如果我这样做 10 次可能会出现问题.问题是,如果我在第 10 个副本中发现了一个错误,我必须审查所有其他项目,而我不想这样做.

I developed an app and I want to duplicate it. I can copy and paste the project but if I do this 10 times can be a problem. The problem is, if I found a bug in the 10th duplicate, I have to review all other projects and I don't want to do this.

有没有干净的方法来解决这个问题?

There is a clean way to solve this problem?

换句话说,我只有一个大代码.我必须部署的应用程序之间的区别是:

In other words, I have only one big code. The differences between the apps that I have to deploy are:

  • 启动器图标
  • HTTP 请求的域
  • 包名
  • 启动画面
  • 应用名称
  • 应用内的一些整数
  • 一些资产

在 Android 中,我用 gradle 来做这件事,特别是用味道.我如何用 Swift 做同样的事情?

In Android, I do this with gradle, in particular, with the flavors. How I can do the same with Swift?

创建具有多个目标的单个项目.每个目标都有不同的 info.plist 和您需要的任何其他更改,但共享源.

Create a single project with multiple targets. Each target would have a different info.plist and whatever other changes you need, but shared source.