Open Legion2 opened 2 years ago
Tried add("kspIos", myKspPlugin)
on v1.6.10-1.0.4
and it works
With 1.6.20-1.0.4
it does not work. We use ios()
to add the ios targets in the kotlin dsl.
add("kspCommonMainMetadata", project(":klue-compiler"))
add("kspAndroid", project(":klue-compiler"))
add("kspIosArm64", project(":klue-compiler"))
add("kspIosSimulatorArm64", project(":klue-compiler"))
add("kspIosX64", project(":klue-compiler"))
add("kspJs", project(":klue-compiler"))
It works in Kotlin 1.8.20.
add("kspCommonMainMetadata", project(":klue-compiler")) add("kspAndroid", project(":klue-compiler")) add("kspIosArm64", project(":klue-compiler")) add("kspIosSimulatorArm64", project(":klue-compiler")) add("kspIosX64", project(":klue-compiler")) add("kspJs", project(":klue-compiler"))
It works in Kotlin 1.8.20.
This still only generates code for code for individual targets and commonMain but not iosMain.
Found workaround, but it works only for extensions.
Koin example: You can add following code to your iosMain
sourceSet:
package org.koin.ksp.generated // package should be same as your generated code
import org.koin.core.module.Module
@Suppress("UnusedReceiverParameter")
val Any.module: Module
get() = throw RuntimeException("Koin module was not generated. Add ksp for all your targets")
On iosMain
IDE will recognize the above extension, but on more specific target (e.g. IosArm64
) it will use generated code instead, as val Module.module: Module
is a better match than val Any.module: Module
.
Is there a formal solution now?
+1 Facing the same issue
This seemingly unrelated comment is another (imho, less hacky) workaround for the iosMain
target https://github.com/JetBrains/compose-multiplatform/issues/4928#issuecomment-2151021584
We use the shorthand
ios()
function to configure common ios source sets and we only have code in theiosMain
source set. However ksp generates code into the IosX64 and IosArm64 source sets. For both source sets, identical code is generated, but we cannot access the definitions from theiosMain
source set.If we try to configure
add("kspIos", project(":processor"))
we get the following error:Configuration with name 'kspIos' not found.
Either the commonization task should run on the generated sources and generate the common definitions or ksp should generate code for the
iosMain
source set.