I'm trying to update a JVM app to Kotlin/Native. I...
# kotlin-native
a
I'm trying to update a JVM app to Kotlin/Native. In order to minimize changes, I want to match the existing code. Can I set an entrypoint that is a main function within an object?
Copy code
package x.y.z

object MyApp {
  @JvmStatic
  fun main(args: Array<String>) {...}
}
I've tried setting the entrypoint as
x.y.z.main
,
x.y.z.MyApp.main
, and
x.y.z.MyApp
and none work.
Copy code
e: Could not find 'main' in 'x.y.z.MyApp' package.

FAILURE: Build failed with an exception.
i
Nope. main function entrypoint is supported on jvm only apps. I would suggest to download and run jetbrains compose multiplatform template, inspect all target entrypoints,and slowly migrate your code there.
h
I don’t think using an object is supported. Kotlin native/c needs a static function and there is no @CNative annotation so “you” need to instance the object first.