When we refactor something, we cannot escape having to check somehow that the project is left in a consistent state.
If you have people working on a module as a product, and it’s up to them to integrate that module back into the project, it will be their responsibility to make sure the project compiles.
If on the other hand, those developers are only responsible for the module, and somebody else will use it (like any other dependency) it will be that someone else’s responsibility to check that the project is OK after a change. It’s like when something changes in a 3rd party dependency, like RxSwift for example.
Having said that, if you have a CI environment set up properly, each PR could trigger a build, or unit tests, making it quite easy to catch the kind of mistakes you are dealing with. So, when pushing something into a module, you could build everything that depends on that module automatically and run Unit or UI tests.
I hope I understood your problem and that my answer helps you in some way.
Thanks for reading!