swinject

Swinject - Ambiguous reference to member

☆樱花仙子☆ 提交于 2020-02-02 05:36:06
问题 I am using Swinject in my Swift 3 app. When I tried let container = Container() container.register(NetworkModeling.self) { _ in Network() } I get an error saying Ambiguous reference to member 'register(_:name:factory:)' What is wrong here? 回答1: I faced the same issue and i think compiler could be a bit more verbose in this case. Anyway, my problem was on my side, not in Swinject Check the following: NetworkModeling and Network are visible in scope of your registration (they are public , or

Swinject service class without parameters failing to register in .container scope with Swift 3.0: why?

浪尽此生 提交于 2019-12-24 08:25:47
问题 I've created a super simple protocol: protocol IndependentProtocol {} and service: class IndependentService: IndependentProtocol {} and the following Swinject registration works: defaultContainer.register( IndependentProtocol.self ) { _ in IndependentService() } but the following one does not: defaultContainer.register( IndependentProtocol.self ) { _ in IndependentService() }.inObjectScope( .Container ) error given is: Ambiguous reference to member 'register(_:name:factory:)' and