I’m trying to access my generated code from unit tests so I added this ```sourceSets.commonMain { ...
j
I’m trying to access my generated code from unit tests so I added this
Copy code
sourceSets.commonMain {
    kotlin.srcDir("$buildDir/generated/ksp/commonMain/kotlin/")
}
sourceSets.commonTest {
    kotlin.srcDir("$buildDir/generated/ksp/commonMain/kotlin/")
}
But I still get a
Source file or directory not found
. What should I do to fix that?
If I replace
$buildDir
with
build
, I then get this
Copy code
Task :example:linkDebugTestIosX64 FAILED
...
Compilation failed: IrClassPublicSymbolImpl for com.jeantuffier.statemachine/MyClass|null[0] is already bound: CLASS CLASS MyClass modality:SEALED visibility:public superTypes:[kotlin.Any]

 * Source files:
 * Compiler version info: Konan: 1.7.10 / Kotlin: 1.7.20
 * Output kind: PROGRAM
I can actually run my unit tests mannually on the jvm and it works. But the error comes again when I try to run the unit tests on ios.
t
Adding a source from main source set to the test source set might cause multiple-definition issues: one from the source, and the other from the dependency. Do you really need to access the generated code? If you know the class names,
Resolver.getClassDeclarationByName
returns the compiled classes.
j
That seems to solve my issue, thanks!
120 Views