Hi, I’ve searched around but can’t find a definitive answer for this, hoping someone can help.
Is it possible to interop between Swift and compose multi platform on macOS? I know it’s designed to do that on iOS but as far as I can see as macOS target runs on a jvm this isn’t possible (at least not possible in the simple manner it is on iOS).
Also I assume it isn’t possible to embed Swift ui views on a macOS target like it is on iOS?
Thanks!
l
Landry Norris
06/03/2024, 5:36 PM
You'll have to go through the JNI to call into Swift code from JVM. There is an experimental macOS native target for Compose Desktop, but I think they primarily use it for debugging, so last I tried it, it wasn't very complete.
Landry Norris
06/03/2024, 5:39 PM
To my knowledge, Swing (which Compose can interop with) doesn't have to ability to embed SwiftUI or UIViews inside, so I don't think there's a direct interop path there.
t
Tim Douglas
06/03/2024, 6:04 PM
Many thanks for the response, that’s unfortunately what I expected.
Since posting this I’ve found this GitHub issue too where JetBrains respond about the native macOS target confirming as you said it’s for internal use, and doesn’t sound like there are are any plans for that to change.
https://github.com/JetBrains/compose-multiplatform/issues/4580
l
Landry Norris
06/03/2024, 6:25 PM
I'd check for a Java or Swing port of what you're looking for, since both of those platforms interop with Compose Desktop, and have been around long enough that there's likely an implementation of what you want.
t
Tim Douglas
06/03/2024, 6:43 PM
Thanks, it was for the native apple sign in ui and to embed Apple Maps, which I think won’t be possible without the interop to Swift and swiftui (or appkit) views (although I appreciate there are other map providers it would work with like in the photo gallery example app).
Appreciate it would be a lot of work to add as its own platform, a shame though as for the use case I’m thinking of it makes the iOS and Mac app less consistent with each other.