-
-
Notifications
You must be signed in to change notification settings - Fork 68
Description
Hi there, I believe that this issue has popped up in the past, and apparently it has been solved? However, I'm finding it difficult to replicate the correct result.
My goal: Get expect-actual module declarations to work in Koin Annotations.
My code:
- @KoinApplication (from my composeApp KMP module)
- the expect class (from my core:location module)
- two actual classes, a koin annotations module for androidMain and jvmMain respectively (same)
- my dependencies ksp block (same)
package com.carebond.health_tracker.core.di
import ...
@KoinApplication(
modules = [
LocationCorePlatformModule::class,
]
)
object MyApp
This is in the commonMain module:
package com.carebond.core.location.di
@Module
expect class LocationCorePlatformModule()
Below is the actual class for androidMain:
package com.carebond.core.location.di
@Module
@ComponentScan("com.carebond.core.location")
actual class LocationCorePlatformModule
@Single
fun provideFusedLocationClient(context : Context) = LocationServices.getFusedLocationProviderClient(context)
And below is the actual class for jvmMain:
package com.carebond.core.location.di
@Module
@ComponentScan("com.carebond.core.location")
actual class LocationCorePlatformModule
And lastly, my ksp dependencies block:
dependencies {
add("kspCommonMainMetadata", libs.koin.ksp.compiler)
add("kspAndroid", libs.koin.ksp.compiler)
}
Error:
Expected module has no actual declaration in module <location> for JVM
Error source:
package org.koin.ksp.generated
expect public val com.carebond.core.location.di.LocationCorePlatformModule.module : org.koin.core.module.Module
This is all my attempt to move from Koin to Koin annotations. In Koin, what I would do is perform an expect-actual on a val of type `Module':
expect val tempModule : Module
Then in the actual modules, I'd do this:
actual val tempModule = module{
single<MyClass> { MyClass(get<Context>() }
}
So now, I'm trying to move over to Koin Annotations, if that is even possible. Please let me know if you need additional information and/or context.
Current versions:
- Koin annotations : 2.3.1
- Koin core : 4.1.1
- Ksp : 2.3.2
- Kotlin : 2.3.0