Port over iOS SwiftUI app

Hey there,

I have an iOS SwiftUI app where I invested quite some time. Now I want to bring it to more platforms like Android and maybe later Windows. Is there an easy way to port it over? That would be one or two weeks maximum of work?

You could use a framework like SwiftCrossUI. It doesn't have every feature SwiftUI has yet, but this is the exact use-case we would like to support. SwiftCrossUI also runs on iOS devices, so you could share the same code for all platforms instead of having to do some #if dance to use SwiftUI on iOS.

6 Likes

Skip seems to be one of the best options for Android. It does not currently officially support Windows but there are open feature requests.

1 Like

Thank you, @bbrk24 and @matthewruzzi , for your reply.

Are SwiftCrossUI and Skip already in production, or are they still in beta?

I have a few questions about them:

  • If I use new SwiftUI APIs, will this break the Android version?
  • Are there persistence frameworks that work across both platforms?
  • What if I need Android-specific libraries?
  • Do I still need Kotlin for GPS, camera, and network-related functionality?

Here are some lists of apps that use Skip:

https://play.google.com/store/apps/developer?id=The+App+Fair+Project

I don't know the full answers to your other questions. You should search the Skip documentation and forums.

SwiftCrossUI is unique (as far as I'm aware) in that it supports every major desktop and mobile operating system while using native widgets.

To answer your questions:

  • Production use: Video Village is using SwiftCrossUI in production on Linux (and soon Windows)
  • Using new SwiftUI APIs: SwiftCrossUI has to manually implement each new API that SwiftUI introduces. So yeah, if you want to use new SwiftUI APIs you'd have to implement or request them, and that could take a while for more complicated features. On the other hand, if the feature is just a convenience API then usually you only have to add it in one place because SwiftCrossUI uses a backend abstraction layer and implements the developer-facing API surface on top of that abstraction layer, avoiding duplication.
  • Persistence frameworks: @MiaKoring recently released Amethyst Vein, a data persistence library with support for both SwiftCrossUI and SwiftUI under the hood. It's backed by sqlite
  • Android-specific libraries: SwiftCrossUI goes hand in hand with Swift Bundler, a bundling tool that can produce MSI installers for Windows, APKs for Android, .apps for Apple platforms, etc. That's where support for custom Android-specific libraries would go. We don't support it yet but it is something that has been requested. In my opinion it should be relatively easy to implement, I just haven't had a proper reason to invest time in that yet. If you'd like to try out SwiftCrossUI + Swift Bundler I'd be happy to hack up a proof of concept of that feature at some point.
  • Accessing platform APIs: SwiftCrossUI doesn't come with a platform abstraction (...yet). It's something that I want to look into eventually but it'd be a pretty large undertaking and I'm already busy enough with SwiftCrossUI and Swift Bundler. For now, the best approach is to use PureSwift/Android (moreSwift's fork of that more specifically) which gives you access to most Android system APIs from Swift via JNI. For example, here are their bindings for LocationManager. You'd then have to implement your platform integrations once for each platform that you support. It's not the best, but I don't think there's anything better if you're targeting iOS + Android + Windows.

I should add that SwiftCrossUI's primary focus has been desktop since the start. Our iOS and Android backends are our two newest backends. We'd love to focus more on getting our mobile support up to scratch, but the project only has one paying client at the moment, and their needs are on the desktop as well, so work on the mobile backends is mostly in my free time (and the free time of SwiftCrossUI's wonderful open source contributors).

If you're only targeting mobile, then Skip's the production ready solution. If you're targeting mobile and desktop, then there's no perfect solution, but I believe that SwiftCrossUI is the furthest along if you want to write cross platform applications that use native UI components under the hood in Swift.

Swift Bundler will also need a bit more work in order to support distributing apps on the Google Play Store as well.

3 Likes