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

MarkRS

12/20/2021, 1:38 PM
Can we access Swift classes from shared code, or is it just "foundation" classes, and what's the definition of those if that's the case? What I really want is Swift's Path class, but suppose I could settle for CGPath
m

mkrussel

12/20/2021, 2:02 PM
There's no interop with Swift. It's possible to interop with Swift code if they are using
@objc
to be usable from Objective-C. CGPath is part of Core Graphics so that is one of the interops Kotlin provides for you out of the box, so you can use it. Import from
platform.CoreGraphics
🙏 2
k

kpgalligan

12/20/2021, 4:11 PM
The easiest way to use Swift is to make an interface in Kotlin and pass in an implementation from Swift on app start. I'm not familiar with Path or your use case, so I can't say that this makes sense, but it's often what I do if cinterop is going to be a hassle and/or if something isn't available.
m

MarkRS

12/20/2021, 4:16 PM
Thanks for that @kpgalligan, I'm going to have to think about that. I may (well) have more questions later 🤔
11 Views