wbertan
08/17/2021, 9:24 AMkoin.get(objCObject: type) *as*! T
in Swift and it works, we are calling it in SceneDelegate
willConnectTo
.
When opening the app, all works, putting the app in background, still works, coming back still works. After some time the app in Background, we can see a bunch of crashes in that line on SceneDelegate
trying to get
the dependency.
The object I’m trying to get in SceneDelegate
is the IsAuthenticatedUseCase
(hence I’m putting everything it needs to actually creates its own dependencies - in 🧵).
koin
is created and started in SceneDelegate
, or the error would be a nil
if it wasn’t.
Non-fatal Exception: InstanceCreationException
Could not create instance for [Singleton:'my.package.common.core.authentication.IsAuthenticatedUseCase']
Sorry for the stacktrace, we are using CrashKiOS to actually be able to see this crash, will post the stacktrace, and definition of dependencies in 🧵wbertan
08/17/2021, 9:25 AMsingle<Settings>(qualifier(SettingsQualifier.ENCRYPTED)) {
KeychainSettings(KEYCHAIN_SERVICE_NAME)
}
single<WebAuthRepository> {
WebAuthRepositoryImpl(
settings = get(named(SettingsQualifier.ENCRYPTED)),
)
}
single<MutableStateFlow<Boolean>>(named(AuthenticationQualifier.AUTH)) {
val isAuthenticated = get<WebAuthRepository>().refreshToken != null
MutableStateFlow(isAuthenticated)
}
single<IsAuthenticatedUseCase> {
IsAuthenticatedUseCaseImpl(
isAuthenticatedMutableStateFlow = get(named(AuthenticationQualifier.AUTH)),
)
}
wbertan
08/17/2021, 9:25 AM