I worked on Dip version for swift 2.3, but after migrating to Swift 3 I have to move to Dip v5.0.2 and my VIPER module assemblies stop working. Circular dependencies doesn't injecting.
This is one example of the module assembly.
import Dip
protocol OnboardModuleFactory {
func OnboardModule() throws -> (OnboardModuleInput, OnboardViewInput)
}
class OnboardModuleAssembly: OnboardModuleFactory {
let moduleContainer = DependencyContainer() { container in
let presenterDefinition = container.register(.shared) { OnboardPresenter() }
.resolvingProperties { container, presenter in
presenter.router = try container.resolve()
presenter.view = try container.resolve()
}
let routerDefinition = container.register(.shared) { OnboardRouter()}
let viewDefinintion = container.register(.shared) { OnboardViewController()}
.resolvingProperties { container, view in
view.output = try container.resolve()
}
// type forwarding
container.register(presenterDefinition, type: OnboardViewOutput.self)
container.register(presenterDefinition, type: OnboardModuleInput.self)
container.register(viewDefinintion, type: OnboardViewInput.self)
container.register(viewDefinintion, type: OnboardViewController.self)
container.register(routerDefinition, type: OnboardRouterInput.self)
}
func onboardModule() throws -> (OnboardModuleInput, OnboardViewInput) {
let view = try moduleContainer.resolve() as OnboardViewController
// view output is nil
let presenter = view.output as! OnboardPresenter
return (presenter, view)
}
}
I worked on Dip version for swift 2.3, but after migrating to Swift 3 I have to move to Dip v5.0.2 and my VIPER module assemblies stop working. Circular dependencies doesn't injecting. This is one example of the module assembly.