Modularized the project using Tuist. I made RepositoryAssembly and UseCaseAssembly on the Data module and Domain module. Assembler is located in InjectManager and runs in AppDelegate in the App module.
// InjectManager.swift
public struct InjectManager {
public static func inject(container: Container) -> Assembler {
return Assembler([
RepositoryAssembly(),
UseCaseAssembly()
], container: container)
}
}
...
private var assembler: Assembler!
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
assembler = InjectManager.inject(container: InjectContainer.container)
return true
}
...
Also, when performing InjetcContainer.container.resolve in MainFeature module, the following error is displayed.
Swinject: Resolution failed. Expected registration:
{ Service: FetchRankingListUseCase, Factory: Resolver -> FetchRankingListUseCase }
Available registrations:
MainFeature/MainInteractor.swift:41: Fatal error: Unexpectedly found nil while unwrapping an Optional value
2022-04-26 23:36:21.127977+0900 GRIG[5952:4943332] MainFeature/MainInteractor.swift:41: Fatal error: Unexpectedly found nil while unwrapping an Optional value
When I print the InjectContainer.container,
[
{ Service: FetchRankingListUseCase, Factory: Resolver -> FetchRankingListUseCase, ObjectScope: graph },
{ Service: GRIGRepository, Factory: Resolver -> GRIGRepository, ObjectScope: graph }
]
Why is this error coming out? Could you tell me how to solve it?