Manage dependencies in modular app

Question or problem

Hello, i’m trying to built a modular app with tuist + swinject as DI. Let’s say i have:

  1. Main App target
  2. Features A, B. Each feature has it’s own interface and implementation target
  3. Something like DesignSystem as a core module.

In main app module i add all features (A,B) and all core modules (DesignSystem) as dependencies to create a common DI container to pull out dependencies later in feature modules.

In a feature module:

  1. In interface target i add all core module as dependencies
  2. In implementation target i add all core modules + FeatureName-Interface of the current as dependencies.

My first question: is it correct approach?

My second question: let’s say i want to open feature module B from module A. Then in module A i’m writing something like “import ModuleBInterface” and do some routing. Everything works but sometimes i get an error where Xcode cannot find a module. So do i need to add ModuleBInterface as a dependency to ModuleAImplemenation target? If yes, is there are any tips how can i automatically update dependencies list based on imports?

  • Tuist version: 4.48.1

I decided to create a python script to manage implicit dependices list based on imports but i’m wondering if there are any built-in tools

Hey @ardavydov :wave:

I would consider PointFree’s swift-dependencies library or using @TaskLocal directly which is what we do at Tuist.

Yes, that’s a valid approach. Whether to use interface modules or not very much depends on your use case and there’s no right or wrong answer – it depends.

There’s not an automated way to include new dependencies in the Tuist manifests – and I don’t think graph changes should be automated based on source changes. Graph changes might have a lot of consequences for your projects and it’s imho better to be explicit about these.

You might be interested in using the tuist inspect implicit-imports to catch implicit imports :wink: