I know that you can only build native iOS modules on macOS. That’s unfortunate (and yeah, Apple’s fault, not Kotlin’s), but it’s okay with me as long as I can just do the development on my Windows machine.
But, can you?
My development environment is IntelliJ IDEA. I’ve set up Mobile Shared Library (one of the options under Kotlin in New Project). Everything looks fine, but whenever I try to use Objective-C stdlib stuff in the iOS module (e.g. import platform.Foundation
…), I get “Unresolved reference: platform”. Is this just expected on Windows? Can I not even do the development on a windows machine? Or, is it some problem with my Gradle setup, or my IDEA setup? Does anyone know? Has anyone successfully developed for Kotlin/Native targeting iOS on Windows, and could give me some pointers?
I encountered this bug as well. Going to 1.4-M1 solved.
Thanks for the suggestion! I tried it, but I don’t really see any changes. If you don’t mind and you have a minute, could you show me what your build.gradle file looks like? Might help me see what I’m doing wrong.
Have a look at my GitHub, in particular, firebase-multiplatform and KGraph.
firebase-multiplatform has a really ocmpelx build script tho and uses the buildSrc
.
Yeah, I have no idea what’s going wrong. I updated my Kotlin IntelliJ plugin to use the 1.4 EAP channel, then I cloned your firebase-multiplatform repo and opened it up in IntelliJ, I’m still getting the issue I initially described. Maybe this just isn’t ready for use in my situation yet, I’m not sure it’s really worth it to invest my time much more into it.
K/N is still in early phase. You have to take that into account, bugs will happen (but I must say I encountered very very few lately) and APIs surfaces will change. Also performances are not that great as well yet, though I’m confident that when it will be out of beta the K/N team will quickly iterate for performance
My personal opinion is that while K/N is great because of Kotlin itself (duh!), the killer feature is the tooling (GRADLE FTW!). It definitely worth investing some time into understanding K/N and toying with it.
Choosing it as you primary technology for you app is up to you! Many big companies are already using K/N and they are pretty happy, while others are not!
You may try cloning KGraph and check if it build! Try the dev
branch as well, even tho it may not compile for other reasons
Oh wait I misread the title! That is not bug! Bindings for Apple libraries are built by the K/N plugin! Which means that they cannot be built on Windows!
In my examples I wrote KGraph using solely common
sources, while firebase-multiplatform has the Apple side built under macOS!
Isn’t there a way to access the Kotlin bindings for Apple libraries even on a Windows system?
My goal is to write the code in my IDE on Windows (with proper completion) but not necessarily build any executable or run any code (that will be done on macOS on the CI). I just would like code completion on Windows, so that would technically just require the Kotlin bindings without the actual Apple runtime.
Yeah, that’s what I was hoping for, although I never did find any indication that it was possible.
I just found out that it is possible, thanks to @LouisCAD 's Gradle plugin called CompleteKotlin.
Here is the related Slack discussion: