Use Java codebase with multiplatform SwiftUI app

I’m creating an app using SwiftUI, and I would like to incorporate a small Java codebase that I created for the Android version of the app. Is there a way to package the Java code to work on iOS and macOS

Answered by DTS Engineer in 841847022

We already touched on this in your other thread. Honestly, I’m surprised you didn’t follow up there.

As I mentioned on that thread, the focus of Swift’s Java integration is on the Swift on Server. It’s likely that you could reasonably make this work on the Mac as well. Getting it to work on iOS would be quite challenging because Java and iOS have traditionally not been the best of friends. So, I think your first step here should be to ask whether it’s possible to run Java code at all on iOS. Once you have an answer to that, you can then assess the Swift Java interoperability story.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is there a way to package the Java code to work on iOS and mani macOS without having to complicate the project to the point where it would be easier to rewrite the Java code in Swift and have to work harder to update the app on each platform separately?

No, there is not.

Perhaps this would be an opportunity to try an AI solution to translate from Java to Swift.

Accepted Answer

We already touched on this in your other thread. Honestly, I’m surprised you didn’t follow up there.

As I mentioned on that thread, the focus of Swift’s Java integration is on the Swift on Server. It’s likely that you could reasonably make this work on the Mac as well. Getting it to work on iOS would be quite challenging because Java and iOS have traditionally not been the best of friends. So, I think your first step here should be to ask whether it’s possible to run Java code at all on iOS. Once you have an answer to that, you can then assess the Swift Java interoperability story.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Use Java codebase with multiplatform SwiftUI app
 
 
Q