Search code examples
androidioskotlinmobilekmm

KMM - Unresolved reference: platform for IOS application


Hellow. I have a trouble with template KMM application. It got an error after I created new KMM application - in shared IOS app module it cannot find package platform. It's on kotlin. Adroid app works well.

Need to say, that I works on window by Android studio. I know there are troubles to start IOS app on window, but I do not want to start or build app - I want to just it find the reference platform.

I tried to find some dicisions. There are the same questions, but nobody can answer them.

Code with trouble:

import platform.UIKit.UIDevice // here there is the error

actual class Platform actual constructor() {
    actual val platform: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}

Solution

  • This question is a bit strange: how do you think iOS application will compile and work on a Windows computer?

    To make KMM work on both OS you need a Mac. This is the reason why you are not able to find "platform.UIKit.UIDevice" on your machine.