I just got an official announcement email about kotlin native integration for Clion. An decided to try it. I’ve updated my Clion to EAP version, but encountered some problems right from the start.
The main problem is that I work on Windows and Clang for windows does not support LLVM. Clion 2017.3 supports multiple toolchains, but on Windows I can choose only between MinGW and Cygwin (by the way I can’t understand why anyone still use it now, when we have Ubuntu for windows). I have LLVM installed on my system. but Clion just does not allow this toolchain type.
The second problem, that there is no promised kotlin/native project available in “new project” dialog. I believe it is connected to problem one.
And the last, but still very annoying problem is that Clion does not currently support Gradle. I know that CMake is much more popular in native ecosystem, but for people from JVM ecosystem, CMake is a huge step back. Also it just does not make sense to have different build systems for different projects now that gradle have full support for native projects.
Latest versioin of CLion and kotlin-native allows creation of project on windows, but it uses some complicated CMake patchwork. Without a lot of CMake expeience it is hard to underdtand. Examples on site use gradle plugin. Also, since my own kotlin-native atempts are a part of larger multiplatform build, I had to work with larger project in idea and debug the subproject with CLion. In the end, I just switched completely back to IDEA saccrificing debugging and using only gradle.
Gradle plugin also has a lot of unresolved issues like IDE integration and undocumented dependencies lifecycle. I decided to wait for release and use cpp + gradle for small parts of native code I need for now. Still, kotlin-native is my exppectation of thee year.
Exactly. The demo project from that plugin is way more complex than the examples from the KN repo. And strangely, the examples in KN repo use gradle to build while the one from KN plugin use CMake…
I think according to the examples in the KN repo. The KN is already pretty solid to cover many cases for mobile clients code sharing.
I’m able to build a project via gradle easily which can produce an iOS framework which then consumed from the swift side. Pretty decent. The only limitation is that it only supports kotlin-std-lib, as I don’t know how to add KN libs as gradle dependencies.
Just some barebone template will be very helpful. And as more people from mobile land will get involved.
So according to your words. You sorted it out? @darksnake? I mean, sharing code between Android and iOS(this part should be easy). And build using gradle (using platform specific API from KN)? Or can you get auto-completion from IDEA for KN’s platform specific API (I don’t know how to do that, a big win if could, but first need to sort out project dependencies)?
It might be better that the project:
Use multi-platform project (As it now doesn’t support KN)
Use gradle to build, but if a minimal setup is viable, I think CMake could do.
I managed to start the project both using CMake in CLion and gradle in IDEA. Also I managed to generate wrappers for cpp source using gradle interop option. But that’s all. In IDEA gradle project does not integrate well with IDE. In order for IDEA to recognize kotlin sources I had to also apply kotlin-jvm plugin (and never use its primary build task). Even in this case IDE does not recognize kotlin-native standard library or interop modules. It compiles though.
As for CMake. I do not have a lot of experience with it, so I could not understand how does kotlin-native build works in it. It has a lot of auxilary files with custom made scripts, some of them are obsolete and some do not work on Windows.
By the way, I would be very disappointed if for some reason JetBrains will decide to use CMake as a primary build system for kotlin-native. Gradle native support is not mature enough, and not documented enough, but event in its current state it is better than CMake.