Cycle Dependency problem

Hi, i have a project i.e.
A, B, C ... all these 3 are added in workspace.

now i want A to communicate to B and vice versa. but if i add framework as dependency then it says "Cycle dependency error". we are not able to communicate like this ?

This is because when building project A, the Xcode will see that it needs to build project B ("and vice versa" part). Looking at project B it will see that it depends on project A. This way you get the cyclic dependency. You can break it by either:

  • making A depend on B
  • making B depend on A

and NOT both.

1 Like

If you really do need 'two-way' API awareness, those components need to be part of the same module. If you want to keep some parts of A and B separate then you could create a separate module X which depends on A and B and provides the 'common' parts of A and B that needs to be mutually aware (alternatively, you could have A and B depend on X, depending on the actual dependency graph you're working with).

If portions of A and B are so inexorably linked that you can't pull it apart in that way, they likely deserve to be a single module.


Very well put!

Another possibility is to add a protocol in module A defining what it has to say to module B. Then module B can import module A and initialize it with a class or struct that implements that protocol. (There could also be more than one protocol.)


the B part of project is not yet been made (initialized). how can he listen to protocols ?

thats exactly what i did. i was just curious that why 2 projects cant be treated this way.

Terms of Service

Privacy Policy

Cookie Policy