https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
f

felislynx

10/11/2023, 7:50 AM
Hi, is it possible in iosMain to have:
Copy code
actual typealias Screen = View
(SwiftUI View). I can't import it, i see there is a UIView but it is not the same thing
l

Landry Norris

10/11/2023, 8:04 AM
SwiftUI View is a Swift struct, which cinterop doesn't support. Swift structs have copy mechanics that don't match well with any existing Kotlin constructs.
f

felislynx

10/11/2023, 8:07 AM
@Landry Norris i've also asked this to bard and it gave me this: import kotlin.native.objc.OCClass actual typealias Screen = objc.OCClass(SwiftUI.View) what do you think about this?
I mean i just want to have this typealias and i don't want to use any methods
l

Landry Norris

10/11/2023, 8:10 AM
LLMs like Bard aren't always reliable when it comes to generating code, especially for new and niche technologies (SwiftUI would be too new for there to be a lot of resources and Kotlin/Native has changed a lot since knowledge cutoffs). They also often hallucinate code when convenient.
f

felislynx

10/11/2023, 8:11 AM
it is just typealias for common where methods returns Screen (and they are implemented in each platform native code)
l

Landry Norris

10/11/2023, 8:12 AM
As of now, Kotlin doesn't interop with Swift structs, and likely won't without real value types (different from value class), which JVM doesn't support.
f

felislynx

10/11/2023, 8:12 AM
ok, so this is just impossible task
l

Landry Norris

10/11/2023, 8:13 AM
You'd likely be best off with UIKit and UIView.
f

felislynx

10/11/2023, 8:14 AM
Ok, thank you