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

Alex Styl

03/19/2024, 12:50 PM
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

Vlad

03/19/2024, 12:56 PM
Write it in in Obj-c compatible Swift. Pack as a library and add the library to iosMain()
a

Alex Styl

03/19/2024, 1:53 PM
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

Eduardo Ruesta

03/19/2024, 2:29 PM
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

Alex Styl

03/20/2024, 3:08 AM
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

Mofe Ejegi

03/20/2024, 8:37 AM
I wrote a piece on this a while back here also, with a straightforward example.
a

Alex Styl

03/20/2024, 10:39 AM
I came across that article but seemed really complicated for me
👍 1
m

Mofe Ejegi

03/20/2024, 11:35 AM
Fair point, I tried to cover quite a number of areas in that write up.
5 Views