Thread
#multiplatform
    j

    j.l.

    2 years ago
    I was playing around with KMP building, testing some Android/iOS features. This was about a week or two ago. I noticed that whenever I am working in IntelliJ and make updates to the shared code in IntelliJ such as adding a function to a shared class, then switch over to Xcode to try and use this function, it takes a really long time for the function to show up in Xcode's autocomplete. The function is not recognized either and causes compilation errors. Sometimes it takes so long that I have to invalidate caches and restart in order for the function to show up in Xcode. Just thought I would mention this. Anyone else having issues like this? Even if I edit the shared code in Xcode, the function/variable is not recognized. Also, there is no kotlin syntax highlighting in Xcode (not sure if this is possible to acheive), that is why I use IntelliJ b/c the syntax highlighting makes life a lot easier. Using 2 IDE's is probably not the ideal way to go about things. I didn't try doing everything from Xcode. But if developing for multiplatform, eventually you will need at least 2 IDE's if you want to see the app in the emulator. At one point, I had 3 IDE's open (Android Studio, IntelliJ, Xcode) and my laptop crashed. (though I did have a ton of chrome tabs open and other programs running simultaneously). Just thought I'd share my experiences developing multiplat so far. Other than the little inconveniences that I frequently encounter, KMP has been pretty great.
    kpgalligan

    kpgalligan

    2 years ago
    Xcode doesn’t automatically refresh the objc headers right away after you compile them. It is frustrating, but what I do is run a build in xcode which forces xcode to refresh the header. we have a todo to look for a better way to do that. It’s not really Kotlin specific. Xcode indexing can be bad in cases.
    tylerwilson

    tylerwilson

    2 years ago
    The way I do it is to have AS and Xcode open all the time, with AS having an app linked to the Kotlin MP shared project, so that I can code and debug fully on the Android side. Only then do I go over to the Xcode side, build (which as say takes a bit the first time and then write the matching Swift code there. It is also useful to build the iOS framework from within AS, looking for any build issues before even going over to Xcode. gradle <module>:linkDebugFrameworkIos will build in AS and let you see any issues before wasting time in Xcode. My dream would be that AppCode is updated to be aware of KMP so that you could edit Swift and Kotlin at the same time and debug in one IDE. Some day perhaps. Good luck.
    kpgalligan

    kpgalligan

    2 years ago
    Oh, yeah. The xcode plugin is only intended to read. It’s not really intended to edit Kotlin (although you could do light edits). The Swift/Objc code is not looking at the Kotlin. Just the generated Objc header.
    You need to edit in AS or Intellij.
    saket

    saket

    2 years ago
    fwiw I’ve noticed that building my project from Xcode also builds my shared code before generating a framework off it. Only one build is required for every change.
    c

    curioustechizen

    2 years ago
    Then there was the announcement fro JetBrains at KotlinConf that there is going to be a way to run iOS apps from Android Studio (with a closed source plugin). I'm not sure if that means we'll be able to actually develop for iOS in Android studio
    Okay I was wrong. It will not bring code editing features to AS:
    It will not bring language support for Objective-C or Swift
    Source: https://blog.jetbrains.com/kotlin/2019/12/what-to-expect-in-kotlin-1-4-and-beyond/#more-7623