I am trying to build the hello world program for ...
# kotlin-native
p
I am trying to build the hello world program for kotlin native on a macos system. I think the fact I am failing miserably is due to stale documentation. Basically, I tried both downloading from GitHub and using brew. Neither one has konan (is this still a thing?) or kotlinc-native whereas kotlinc -version advertises itself as kotlinc-jvm … Can someone supply a link for a newbie to Kotlin native to build a macos executable for hello world or some simple basic program.
I did manage to find https://github.com/msink/hello-kotlin which gets me off the dime but hides what is really going on for Gradle doing the heavy lifting. Is the kotlin-multiplatform plugin sufficiently readable so that I can figure out what is going on under the hood?
g
To do what is going under the hood you can check Gradle MPP plugin sources
But what exactly you want to know?
Also, are you sure that you need multiplatform? Because if you just build an app for macos pure Kotlin-Native is enough, no need to configure MPP project
p
I thought I was using pure Kotlin-Native by downloading the compiler from Github but there is no kotlinc-native compiler as some documentation suggests I should use.
g
There is Kotlin Native compiler
unzip this TAR file, and just run
bin/kotlinc hello-world.kt
you will get something like program.kexe which is executable mac native binary (without optimisation, dependencies, config etc)
o
but recommended approach is to use IDEA (including free community edition) with Kotlin plugin
1
j
The easiest way to start with Kotlin Native for macOS is to start a new native project in Intellij Idea. It creates a Hello World kexe
c
how can i run the project that idea creates? neither the main class nor the test class offers to run it
g
You can use
runProgram
Gradle task
c
ok no way to run tests from inside idea?
g
Gradle task
yourPlatformTest
For now Idea doesn’t have built-in integration with K/N test runner
j
I am getting this same issue. I try to run
kotlinc-native -version
in the terminal on macOS and the
kotlinc-native
command is not recognized. I installed kotlin on my system and kotlinc is recognized (though it prints
*info:* kotlinc-jvm 1.3.70 (JRE 13.0.1+9)
) I just can't get kotlinc-native command to work for some reason.
g
You installed Kotlin JVM How do you exactly install it?
j
I think it was the default when I installed kotlin. I also have kotlinc-js and kotlinc compilers just as a default. I do not think kotlinc-native comes with kotlin out of the box. You have to install kotlin native separately, if i am not mistaken.
g
Kotlin-jvm + Kotlin-js are bundled together, native is a separate compiler and distribution.
My question was how exactly you installed Kotlin, there are many ways to do that
If you need command line version, just download it from kotlin-native repo
👍 1
j
It took me a while to figure out. The kotlin compiler documentation confused me.