4

I'm developing a Kotlin/Native library for both iOS and Android.

When running ./gradlew assemble I get the release/debug .frameworks with Obj-C Headers.

I can use these .frameworks fine. But I would also like to carry on with documentation of classes and functions when using the code on XCode.

If I use KDoc and document my code:

/**
 * This is a comment about the class I developed.
 * [BaseService] is a class.
 */
class BaseService {

    /**
     * Comments about this val
     */
    val greeting = "Hello"

    /**
     * This function greets the user
     */
    fun greetUser(){
        println(greeting)
    }

}

All of this is lost when bringing it to my iOS project. Because the .frameworks don't carry the KDocs with it.

Is there any way to carry the documentation over to the Obj-C Headers or other auxiliary files when assembling the .framework files? Maybe some Gradle configuration I am missing?

Vitor Hugo Schwaab
  • 1,545
  • 20
  • 31

2 Answers2

1

There is no pre-made option for this, you can upvote an issue here.

Artyom Degtyarev
  • 2,704
  • 8
  • 23
1

You can configure your module's build.gradle.kts as described here:

kotlin {
    targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
        compilations.get("main").compilerOptions.options.freeCompilerArgs.add("-Xexport-kdoc")
    }
}

This enables the ability to export KDoc comments to generated Objective-C headers.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83