Liftric / DIKit

Dependency Injection Framework for Swift, inspired by KOIN.
MIT License
102 stars 17 forks source link

Bug when resolving some dependencies #48

Open sedestrian opened 3 years ago

sedestrian commented 3 years ago

Hello, i have a bug when trying to resolve a dependency that i have in multiple targets

My componentStack is this:

(lldb) po self.componentStack
▿ 8 elements
  ▿ 0 : 2 elements
    ▿ key : AnyHashable(DIKit.ComponentIdentifier(tag: nil, type: Restaurants.RestaurantsLocalDataSource))
      ▿ value : ComponentIdentifier
        - tag : nil
        - type : Restaurants.RestaurantsLocalDataSource
    ▿ value : <Component<RestaurantsLocalDataSource>: 0x600000b0c060>
  ▿ 1 : 2 elements
    ▿ key : AnyHashable(DIKit.ComponentIdentifier(tag: nil, type: Restaurants.RestaurantsRemoteDataSource))
      ▿ value : ComponentIdentifier
        - tag : nil
        - type : Restaurants.RestaurantsRemoteDataSource
    ▿ value : <Component<RestaurantsRemoteDataSource>: 0x600000b0c120>
  ▿ 2 : 2 elements
    ▿ key : AnyHashable(DIKit.ComponentIdentifier(tag: nil, type: RestaurantList.RestaurantListViewModel))
      ▿ value : ComponentIdentifier
        - tag : nil
        - type : RestaurantList.RestaurantListViewModel
    ▿ value : <Component<RestaurantListViewModel>: 0x600000b14360>
  ▿ 3 : 2 elements
    ▿ key : AnyHashable(DIKit.ComponentIdentifier(tag: nil, type: Chopsticks.StartupViewModel))
      ▿ value : ComponentIdentifier
        - tag : nil
        - type : Chopsticks.StartupViewModel
    ▿ value : <Component<StartupViewModel>: 0x600000b043c0>
  ▿ 4 : 2 elements
    ▿ key : AnyHashable(DIKit.ComponentIdentifier(tag: nil, type: Swift.Optional<__C.FIRApp>))
      ▿ value : ComponentIdentifier
        - tag : nil
        - type : Swift.Optional<__C.FIRApp>
    ▿ value : <Component<Optional<FIRApp>>: 0x600000b04360>
  ▿ 5 : 2 elements
    ▿ key : AnyHashable(DIKit.ComponentIdentifier(tag: nil, type: RealmSwift.Realm))
      ▿ value : ComponentIdentifier
        - tag : nil
        - type : RealmSwift.Realm
    ▿ value : <Component<Realm>: 0x600000b14240>
  ▿ 6 : 2 elements
    ▿ key : AnyHashable(DIKit.ComponentIdentifier(tag: nil, type: Restaurants.RestaurantRepository))
      ▿ value : ComponentIdentifier
        - tag : nil
        - type : Restaurants.RestaurantRepository
    ▿ value : <Component<RestaurantRepository>: 0x600000b0c000>
  ▿ 7 : 2 elements
    ▿ key : AnyHashable(DIKit.ComponentIdentifier(tag: nil, type: FIRFirestore))
      ▿ value : ComponentIdentifier
        - tag : nil
        - type : FIRFirestore
    ▿ value : <Component<FIRFirestore>: 0x600000b14300>

The identifier is this:

(lldb) po identifier
▿ ComponentIdentifier
  - tag : nil
  - type : FIRFirestore

But this still finds no matching component in the stack. I have a module providing the dependency in one target (dynamic framework) of my app, and the dependency itself is requested in another target

Schermata 2021-07-09 alle 15 32 00 Schermata 2021-07-09 alle 15 32 31