简体   繁体   English

Xcode的两个项目-一个用于业务逻辑,另一个用于UI?

[英]Xcode two projects - one for business logic, another for UI?

Is what I am suggesting in the tittle possible? 我的建议可能吗?

The main goal is to completely separate the business logic (to be reused in other lightly rebranded apps) and the custom UI for a particular client. 主要目标是将业务逻辑(将在其他轻度重塑的应用程序中重用)和特定客户端的自定义UI完全分开。

That means, I would have the same core, but on top of it would be very small view controllers driving customised UIs. 那意味着,我将拥有相同的核心,但最重要的是,非常小的视图控制器将驱动定制的UI。

I understand that I can have a workspace containing two projects...But should they be peers? 我知道我可以有一个包含两个项目的工作区...但是它们应该是对等的吗? OR should one project consume/include the other one? 或者一个项目应该消耗/包括另一个项目? There is no need for app delegate for UI code. 不需要UI代码的应用程序委托。 It is already in the business logic project. 它已经在业务逻辑项目中。 How should i organise my projects structure so that the latter is able to use the first with business logic? 我应该如何组织我的项目结构,以便后者能够将第一个与业务逻辑一起使用?

You can use different targets: https://developer.apple.com/library/ios/featuredarticles/XcodeConcepts/Concept-Targets.html 您可以使用不同的目标: https : //developer.apple.com/library/ios/featuredarticles/XcodeConcepts/Concept-Targets.html

In the same project you can separate the different implementations (assets, xbis...) using the targets. 在同一项目中,您可以使用目标来分离不同的实现(资产,xbis ...)。 You can also specify different pre-processor flags for each target and use #ifdef 您还可以为每个目标指定不同的预处理器标志,并使用#ifdef

The better design would be, having the business logic in a static library inside your main project. 更好的设计是将业务逻辑放在主项目中的静态库中。 It is not a good idea to mix UI code in a business logic target. 在业务逻辑目标中混合UI代码不是一个好主意。 You can add Bundle to your static library to hold resource files such as plists & etc. 您可以将Bundle添加到静态库中,以保存资源文件(例如plists等)。

I used this approach in one of an enterprise app project. 我在一个企业应用程序项目中使用了这种方法。 So far so good. 到现在为止还挺好。 We can simply scale, extend & modify the business logic without affecting the presentation logic. 我们可以简单地扩展,扩展和修改业务逻辑,而不会影响表示逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM