如何管理多个非常相似的 Xcode 项目的代码 [英] How to manage the code of multiple, very similar Xcode projects

查看:28
本文介绍了如何管理多个非常相似的 Xcode 项目的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候 Stackoverflow 社区,

Greetings Stackoverflow Community,

我承担了统一"4 个移动 iPhone 应用程序的任务,这些应用程序共享 95% 的代码,只有 5% 的不同(这有点过于简化,但没关系).每个应用都有自己的大量资源(媒体文件).

I have taken on the task of 'unifying' 4 mobile iPhone apps that share 95% of the code and differ only in 5% (this is somewhat of an over-simplification, but never mind). Each of the apps has its own hefty set of resources (media files).

在统一"这 4 个应用程序后,我将为这些应用程序添加新功能,主要是这些应用程序将共享的功能.

After 'unifying' the 4 apps, I will be adding new functionality to the apps, mostly functionality that the apps will share.

我希望听到您对管理这些应用代码的最佳方式的意见.这是我目前采取的方法.

I would appreciate hearing your opinions on what's the best way to manage the code of these apps. Here is the approach I'm taking at the moment.

  1. 我只维护一个 Xcode 项目,其中包含所有 4 个应用程序的功能.未在所有应用之间共享的功能包含在一个条件中,例如:if (appName == 'X')...

  1. I'm maintaining only one Xcode project which includes the functionality of all 4 apps. The functionality that is not shared among all apps is enclosed in a condition such as: if (appName == 'X')...

每个应用程序都有自己的 info.plist 文件,所以我有 4 个这样的文件:infoX.plist、infoY.plist、...

Each app has its own info.plist file, so I have 4 of such files: infoX.plist, infoY.plist, ...

在我构建一个应用之前,有两件事要做:一种.在构建设置中,我指定要使用的 info.plist 的名称.湾我确保只有应用程序的资源(媒体文件)在项目中.我删除了其他应用的资源.

Before I build an app, two things are done: a. in the Build Settings, I specify the name of info.plist to use. b. I ensure that only the app's resources (media files) are in the project. I delete the other apps' resources.

由于这些应用的代码有 95% 的相似度,因此只有一个应用来统治所有应用"可以确保当代码升级时,所有应用都可以享受升级.您可以假设这些应用的代码将保持非常相似.

As the apps are 95% similar in their code, having only "One App to Rule Them All" ensures that when the code gets upgraded, all apps enjoy the upgrade. You can assume that the apps will remain very similar in their code.

由于应用程序的媒体文件很大而且很多,我将它们从 Git 存储库中删除.

As the apps' media files are large and many, I'm keeping them off the Git repository.

这一切听起来如何?

非常感谢!

推荐答案

有更好的方法:

A.移至框架

这取决于应用程序的通用部分的通用程度.但是你应该考虑把它的一部分放在一个单独的项目中,这个项目是一个框架.您可以将您的 4 个应用程序链接到该框架.但是,当然,并非一切都会到此为止.

It depends on how generic are common parts of the apps. But you should think about putting parts of it in a separate project that is a framework. You can link your 4 apps against that framework. But, of course, not everything will go there.

B.有不同的目标

当然,您应该有 4 个不同的目标.Xcode 允许您为每个项目或特别是每个目标的每个设置设置构建设置.此外,您可以针对每个目标库自定义构建阶段(包括媒体文件的副本).因此,您不必重命名或删除和插入任何内容.您只需选择一个要构建的目标即可.

For sure you should have 4 different targets. Xcode let you set build settings for each setting commonly per project or specially per target. Additionally you can customize the build phases (including copy of the media files) on a per target base. So you do not have to rename or delete and insert anything. You simply select a target, you want to build.

C.项目树

Xcode 允许您拥有带有通用代码的子项目.也许像你的应用程序的常见基础"类.您可以在单个工作区中为每个应用程序创建不同的项目,所有项目都使用子项目.

Xcode allows you to have subprojects with common code. Maybe things like common "foundation" classes of your app. You can have different projects for each app in a single workspace, all using the subproject.

可能最好的方法是组合,这取决于主题是什么.不过我会从 B. 开始,如果需要,可能会添加其他技术.

Probably the best way is a combination, depending on what is the subject. However I would start with B. and likely add the other techniques, if needed.

这篇关于如何管理多个非常相似的 Xcode 项目的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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