hello-kmp
hello-kmp copied to clipboard
Annotations: Overload resolution ambiguity
I'm trying to get annotations with ksp working in an Android/iOS multiplatform project using the "Framework"-style Xcode integration.
I assume because proper common codegen support is lacking from ksp, this example uses the trick of adding the android generated code to the common source set, to make the generated symbols accessible from common code (in this case, the .module
extension property on @Module
annotated classes):
https://github.com/InsertKoinIO/hello-kmp/blob/664444866293be790bb96c850ad18d49d9891258/shared/build.gradle.kts#L35
I'm using this setup in my project with the only difference being that I have only the iosArm64 and iosX64 targets for iOS (which I figure doesn't make a difference here).
This works fine for Android, but in my case leads to an overload resolution ambiguity when gradle attempts to build the framework, since both the compiler/ksp generated code for the specific iOS source set as well as the explicitly added symbols for Android are visible:
e: /Users/julian/Documents/SoftwareDevelopment/Projects/Flow/flow-shared/src/commonMain/kotlin/de/julianostarek/flow/FlowModule.kt: (27, 30): Overload resolution ambiguity:
public val FlowModule.module: Module defined in org.koin.ksp.generated in file FlowModuleGende$julianostarek$flow.kt
public val FlowModule.module: Module defined in org.koin.ksp.generated in file FlowModuleGende$julianostarek$flow.kt
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ':flow-shared:compileKotlinIosArm64'.
Compilation finished with errors
Mapping back to this example (annotations branch), the above error would refer to the following line:
https://github.com/InsertKoinIO/hello-kmp/blob/664444866293be790bb96c850ad18d49d9891258/shared/src/commonMain/kotlin/com/example/helloworldkmp/di/AppModule.kt#L7
Do you see a way to resolve this that does not involve having to do Koin initialization separately in androidMain, iosMain etc. source sets?
Any updates on this?