Closed Samueljh1 closed 11 months ago
Which Multiplatform targets(Android,iOS,js) are you compiling for?
Which Multiplatform targets(Android,iOS,js) are you compiling for?
I am compiling for Android and iOS. The library code works fine when removing the annotations and calling it directly in Swift/Kotlin (i.e., in native code).
Have you defined your annotated RN module in common code and added this to you gradle config?
dependencies {
add("kspCommonMainMetadata", "de.voize:reakt-native-toolkit-ksp:<version>")
add("kspAndroid", "de.voize:reakt-native-toolkit-ksp:<version>")
add("kspIosX64", "de.voize:reakt-native-toolkit-ksp:<version>")
add("kspIosArm64", "de.voize:reakt-native-toolkit-ksp:<version>")
}
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().configureEach {
if (name != "kspCommonMainKotlinMetadata") {
dependsOn("kspCommonMainKotlinMetadata")
} else {
finalizedBy("copyGeneratedTypescriptFiles")
}
}
Please check that CalculatorRNModuleProvider
is generated in the common code (android/shared/build/generated/ksp/metadata/commonMain/kotlin
) and available in your common code during compilation.
@Samueljh1 Were you able to resolve this? currently facing the same issue.
Have you defined your annotated RN module in common code and added this to you gradle config?
dependencies { add("kspCommonMainMetadata", "de.voize:reakt-native-toolkit-ksp:<version>") add("kspAndroid", "de.voize:reakt-native-toolkit-ksp:<version>") add("kspIosX64", "de.voize:reakt-native-toolkit-ksp:<version>") add("kspIosArm64", "de.voize:reakt-native-toolkit-ksp:<version>") } tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().configureEach { if (name != "kspCommonMainKotlinMetadata") { dependsOn("kspCommonMainKotlinMetadata") } else { finalizedBy("copyGeneratedTypescriptFiles") } }
Please check that
CalculatorRNModuleProvider
is generated in the common code (android/shared/build/generated/ksp/metadata/commonMain/kotlin
) and available in your common code during compilation.
CalculatorRNModuleProvider is generated in my case
public expect class CalculatorRNModuleProvider() : ReactNativeModuleProvider
have this there
but looks like two CalculatorRNModuleProvider
are generated one in androidDebug and the other in androidRelease. The androidDebug version is the one with the error
@Samueljh1 Were you able to resolve this? currently facing the same issue.
No, I wasn't able to unfortunately. I ended up working on a different project so stopped trying to get this to work. Please let me know if you can get this working, however.
Hey, can you share a reproducer project, so we can investigate the root cause of the problem. Without the full picture it's difficult to pin point the exact problem.
Hey, can you share a reproducer project, so we can investigate the root cause of the problem. Without the full picture it's difficult to pin point the exact problem.
Also seeing this. Will try to slap something together.
Hey, can you share a reproducer project, so we can investigate the root cause of the problem. Without the full picture it's difficult to pin point the exact problem.
I have uploaded a zipped version of the reproducer project to Drive for you to download. Here is the link: Google Drive Link. Please let me know if there are any issues with accessing the file.
@boluokvmd thanks for the reproducer, I was able to find the missing configuration, I added kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
to kotlin > sourceSets > commonMain in the shared/build.gradle.kts. I will add this to the readme
You also need to remove the kotlin.srcDir
instructions from the androidMain source set (kotlin.srcDir("build/generated/ksp/android/androidDebug/kotlin")
), which is not needed and causes gradle task dependency issues. Then it successfully builds the project.
@boluokvmd thanks for the reproducer, I was able to find the missing configuration, I added
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
to kotlin > sourceSets > commonMain in the shared/build.gradle.kts. I will add this to the readme
Thanks @Legion2 This solves the problem cc @Samueljh1
I'm closing this as resolved, feel free to reopen if you still have problems.
After following the project setup steps, I tried to build my project after adding the @ReactNativeModule and @ReactNativeMethod annotations (using the example CalculatorRNModule class).
During the build process, the toolkit generates the CalculatorRNModuleProvider.kt file, which then causes the two compilation errors:
The CalculatorRNModule class in my project is defined under commonMain in the shared module.