Сбой: строка Container.swift 242 Container.resolve <A, B> (запись: invoker :) - PullRequest
0 голосов
/ 06 ноября 2018

Я получаю следующие ошибки. Дайте мне знать, что я делаю не так: - Container.swift - это файл в библиотеке Swinject. ссылка: https://github.com/Swinject/Swinject/blob/master/Sources/Container.swift

libswiftCore.dylib             0x107020d38 specialized _assertionFailure(_:_:file:line:flags:) + 164
1  libswiftCore.dylib             0x106eb808c default argument 1 of precondition(_:_:file:line:) + 38
2  Swinject                       0x106c73d20 Container.resolve<A, B>(entry:invoker:) (Container.swift:242)
3  Swinject                       0x106c72384 Container._resolve<A, B>(name:option:invoker:) (Container.swift:192)
4  Swinject                       0x106c74718 Container.resolve<A>(_:name:) (Container.swift:280)
5  Swinject                       0x106c747d8 protocol witness for Resolver.resolve<A>(_:) in conformance Container (Container.swift)
6  ABC                        0x100fddb94 specialized ReminderClient.unscheduleAllExpiredNotifications() -> Promise<Bool> (ReminderClient.swift:151)
7  ABC                        0x100fcf940 specialized AppDelegate.applicationDidBecomeActive(UIApplication) -> () (ReminderClient.swift:21)
8  ABC                        0x100fc00a8 @objc AppDelegate.applicationDidBecomeActive(UIApplication) -> () (AppDelegate.swift)
9  UIKitCore                      0x227ae6a84 -[UIApplication _stopDeactivatingForReason:] + 1256
10 UIKitCore                      0x2273932a0 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 476
11 UIKitCore                      0x227394100 _performActionsWithDelayForTransitionContext + 112
12 UIKitCore                      0x227393058 -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 248
13 UIKitCore                      0x227397d9c -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 368
14 UIKitCore                      0x2276d9118 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 468
15 FrontBoardServices             0x1fd71c5a0 __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke.359 + 228
16 libdispatch.dylib              0x1fa724484 _dispatch_client_callout + 16
17 libdispatch.dylib              0x1fa6c7e58 _dispatch_block_invoke_direct$VARIANT$mp + 224
18 FrontBoardServices             0x1fd75a640 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
19 FrontBoardServices             0x1fd75a2cc -[FBSSerialQueue _performNext] + 416
20 FrontBoardServices             0x1fd75a8e8 -[FBSSerialQueue _performNextFromRunLoopSource] + 56
21 CoreFoundation                 0x1fac7a5b8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
22 CoreFoundation                 0x1fac7a538 __CFRunLoopDoSource0 + 88
23 CoreFoundation                 0x1fac79e1c __CFRunLoopDoSources0 + 176
24 CoreFoundation                 0x1fac74ce8 __CFRunLoopRun + 1040
25 CoreFoundation                 0x1fac745b8 CFRunLoopRunSpecific + 436
26 GraphicsServices               0x1fcee8584 GSEventRunModal + 100
27 UIKitCore                      0x227af0bc8 UIApplicationMain + 212
28 ABC                        0x100ef1c54 main (AppDelegate.swift:69)
29 libdyld.dylib                  0x1fa734b94 start + 4

Код:

Инициировано в приложении стало активным:

func applicationDidBecomeActive(_ application: UIApplication) {

 ReminderClient.shared.unscheduleAllExpiredNotifications()
            .done{successful -> Void in Log.info("Expired reminders cleared successfully \(successful)")}
            .catch{error -> Void in Log.error("Error in clearing expired reminders \(error)")}
    }

func unscheduleAllExpiredNotifications() -> Promise<Bool> {
        guard let reminderManagerUseCase = assembler.resolver.resolve(ReminderManagerProtocol.self) else {
            Log.error("Reminder Manager Initialization Falied")
            return Promise<Bool>(error: ReminderClientError.initializationFalied)
        }
        return reminderManagerUseCase.unscheduleAllExpiredNotifications()
    }

Регистрационный код в сборке:

container.register(ReminderManagerProtocol.self) { r -> ReminderManagerProtocol in
            return ReminderManager(
                reminderCRUDUseCase: r.resolve(ReminderCRUDUseCaseProtocol.self)!,
                scheduler : r.resolve(SchedulerUseCaseProtocol.self)!)
        }

        container.register(SchedulerUseCaseProtocol.self) { r -> SchedulerUseCaseProtocol in 
            SchedulerUseCase(crudUseCase : r.resolve(ReminderCRUDUseCaseProtocol.self)!)
        }

container.register(ReminderCRUDUseCaseProtocol.self) { (r) -> ReminderCRUDUseCaseProtocol in
            let configiration =  r.resolve(PersistantStorageConfiguration.self, name: RemainderAssemblyKey.PersistantStorageConfiguration.rawValue)!
            return ReminderUseCase(storage: r.resolve(StorageContextProtocol.self,
                                                    argument: ConfigurationType.basic(info: configiration))!)
        }

Контейнер. Сдвиг на линии 242

   fileprivate var maxResolutionDepth: Int { return 200 }

    fileprivate func incrementResolutionDepth() {
        if resolutionDepth == 0 && currentObjectGraph == nil {
            currentObjectGraph = GraphIdentifier()
        }
        guard resolutionDepth < maxResolutionDepth else {
            fatalError("Infinite recursive call for circular dependency has been detected. " +
                "To avoid the infinite call, 'initCompleted' handler should be used to inject circular dependency.")
        }
        resolutionDepth += 1
    }

    fileprivate func decrementResolutionDepth() {
        assert(resolutionDepth > 0, "The depth cannot be negative.")

        resolutionDepth -= 1
        if resolutionDepth == 0 {
            services.values.forEach { $0.storage.graphResolutionCompleted() }
            self.currentObjectGraph = nil
        }
    }
...