I have a scenario where there are three modules which have simple dependencies but their packages have circular dependencies (it's caused by one of their test modules. More on this later). The project compiles. I wonder if it's OK to keep using it this way?
More details. The three modules are utils module, custom protocol module, and macros module.
- Utils is the basic module. It doesn't depend on other modules.
- Custom protocol module uses the types defined in utils module, so it depends on utils module.
- Macros module have extension macro which expand extensions for protocols defined in custom protocol module, so it depends on custom protocol module.
The dependency is simple, as illustrated in the diagram.
Ideally their package should have the same dependency. However, as I use macro to implement tests for Utils, Utils package depends on macros package. That caused circular dependency among these three packages.
As Xcode compiles my project successfully, I didn't realize there was circular dependency at first. After I found it, I think I can get rid of the circular dependency by split macros package into two packages, but I'm not sure if it's worth the effort since circular dependency works fine in practice. Does anyone know if it's by design or by accident? Thanks.