In my Compose Multiplatform app, an iOS API I am i...
# multiplatform
a
In my Compose Multiplatform app, an iOS API I am interested about is not available via kotlin multiplatform. Is there a way to write it in Swift and use the class from kotlin? If this is not the best channel to ask, let me know
v
Write it in in Obj-c compatible Swift. Pack as a library and add the library to iosMain()
a
figured it out. Turns out I can use Kotlin code from Swift in my Compose app. had to
import ComposeApp
and rebuild the project on xcode, otherwise xcode doesnt pick it up
e
Hey Alex! its good to know that! can you give me an example of why you need that? if you need an iOS API why you need to import ComposeApp from xcode? Thanks
a
because of the wiring. made a kotlin interface, implemented it in Swift, got a shared
object
between kotlin <-> swift to pass the reference wrote @ https://twitter.com/alexstyl/status/1770085048982913155
❤️ 1
m
I wrote a piece on this a while back here also, with a straightforward example.
a
I came across that article but seemed really complicated for me
👍 1
m
Fair point, I tried to cover quite a number of areas in that write up.