Hello Guys, I'm using Koin 4.1.0-Beta8 in my Comp...
# koin
j
Hello Guys, I'm using Koin 4.1.0-Beta8 in my Compose Multiplatform app with
Copy code
KoinMultiplatformApplication
and getting the whole time the following error only on iOS:
Copy code
[INFO] [Koin] Started 4 definitions in 0.007 ms
Uncaught Kotlin exception: kotlin.IllegalStateException: Koin context has not been initialized in rememberKoinApplication
Check the 🧵 for more context
👀 1
Copy code
@OptIn(KoinExperimentalAPI::class)
@Composable
@Preview
fun App() {
    KoinMultiplatformApplication(config = koinConfiguration {
        modules(
            nativeAuthModule(),
            module {
                single<Config> {
                    AppConfig.config
                }
            },
            commonModules()
        )
    }) {
        val navController = rememberNavController()
        setSingletonImageLoaderFactory { context ->
            newImageLoader(context, true)
        }
        AppTheme {
            RootNavigation(navController)
        }
    }
}
I'm using
KoinMultiplatformApplication
in my App.kt and I'm only importing my modules. I receive the error only on iOS on Android everything works fine. I'm using the following dependencies in my project with version 4.1.0-Beta8
Copy code
# KOIN
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
koin-compose = { module = "io.insert-koin:koin-compose", version.ref = "koin" }
koin-compose-viewmodel = { module = "io.insert-koin:koin-compose-viewmodel", version.ref = "koin" }
Did I miss something in my implementation?
a
interesting, need to check 👍
j
I also ran several times the gradle clean task and invalidated the cache in Android Studio
a
anything you are doing on iOS, that would provoke an injection before Koin context?
j
I'm only using the following injections in my `RootNavigation.kt`:
Copy code
@Composable
fun RootNavigation(
    navController: NavHostController
) {
    val viewModel = koinViewModel<AuthViewModel>()
    val config = koinInject<Config>()
    val lifecycleOwner = LocalLifecycleOwner.current
    val credentials =
        viewModel.credentials.collectAsStateWithLifecycle().value
    val signInState =
        viewModel.signInstate.collectAsStateWithLifecycle().value
But I don't think it does provoke an injection before Koin context
a
ok. Do you have full stack trace?
j
yes, here
I forgot to mention, that I'm using Compose Multiplatform 1.8.0
a
ok
could you help reproduce that?
liek a project snippet ?
j
Yes, pm
👍 1
This issue occurs when I'm using privacySensitive() in iOS Before:
Copy code
import SwiftUI
import ComposeApp

@main
struct iOSApp: App {
    init() {
        MainViewControllerKt.initialise()
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
                .privacySensitive()
        }
    }
}
After:
Copy code
import SwiftUI
import ComposeApp

@main
struct iOSApp: App {
    init() {
        MainViewControllerKt.initialise()
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}