Foso / Ktorfit

HTTP client generator / KSP plugin for Kotlin Multiplatform (Android, iOS, Js, Jvm, Native, WasmJs)) using KSP and Ktor clients inspired by Retrofit https://foso.github.io/Ktorfit
https://foso.github.io/Ktorfit
Apache License 2.0
1.6k stars 43 forks source link

How to generate the `_FooApiImpl.kt` in `commonMain` instead of `jvmMain`? #705

Closed opatry closed 1 month ago

opatry commented 1 month ago

Not sure it's an issue or something I missed, but I noticed that I wasn't able to reach the Ktorfit.createFooApi() extension in my setup, only the deprecated Ktorfit.create<FooApi>() was available.

I have the following project structure:

The _FooApiImpl.kt class is generated in lib1/build/generated/ksp/jvm/jvmMain/kotlin, it appears that because of this, I can't reach the class from :shared/src/commonMain/kotlin.

Is there a way to tweak where the code is generated, or alternatively, generate it in commonMain?

Foso commented 1 month ago

Hi, the code is not generated to commonMain, because your :lib1 is only having a single compile target https://foso.github.io/Ktorfit/knownissues/#kmp-project-with-single-target

opatry commented 1 month ago

Oh, I missed that section in the doc, it explains the issue indeed. Thanks.