SwiftUI as an alternative for Android

February 24, 2022

Using SwiftUI as an alternative for Android for development

For many years, Apple has been known as one of the most innovative tech companies out there. They proved it once again a few years ago by releasing its brand new SwiftUI framework, which helps developers create innovative apps rapidly and effortlessly. Although there are some things that even this company can’t make simple enough for its customers, such as Apple’s fiscal year.

Anyway, what about Android and its alternatives to SwiftUI? The best one is probably Flutter. It is a free and open-source UI framework by Google. Flutter gives developers all the necessary tools to create applications for iOS and Android with a single codebase and programming language.

Another option is MobileUI, which is the first native UI framework based on Java for both iOS and Android. It uses Javascript, CSS, and HTML to create professional multi platform apps with user interfaces that auto-scale to various screen sizes.

What Is SwiftUI?

It is Apple’s framework, which uses the Swift language and helps developers build applications across all iOS platforms without much coding. Although it is brand new, it may feel familiar.

That is not a coincidence, for Apple did not create it from scratch. Before that, developers had UIKit, AppKit, and WatchKit. Unlike those, SwiftUI uses a declarative programming paradigm. In layman’s terms, developers do not need to write code for every little action anymore; instead, they can let the framework do everything for them.

SwiftUI provides developers with lists, stacks, and buttons to build user interfaces easily and quickly. Support for core technologies, such as accessibility and adaptive layouts, is also built into the toolkit.

Is There a Way to Make a SwiftUI App for Android?

If you have an app built in SwiftUI, you may wonder, “How can I reuse my code on an Android device?” Well, that is not possible, as they are incompatible. Java and Kotlin are used to create Android apps, while Swift is used for iPhone apps. Objective-C is the only one that works with both and helps with iOS to Android conversion. Otherwise, you will have to rewrite the entire code. To create an Android app, you may want to consider Jetpack Compose.

What Is Jetpack Compose?

Jetpack Compose is Android’s framework introduced by Google and used for building native UI. It also uses declarative layouts. Its main draw is that it allows developers to write less code, which leads to fewer potential bugs.

Furthermore, it uses Kotlin, which makes it possible to use all Kotlin structures directly in one’s view code. IF statements can be used to choose what should be rendered.

Finally, with Compose, you can call Compose code from Views and Views from Compose. Most common libraries work with Compose, so it is possible to start adopting anytime, anywhere. These and many other features make Jetpack Compose great, but how does it compare to SwiftUI?

SwiftUI vs. Jetpack Compose

A big difference is that the development process of Jetpack Compose was designed with the help of a large number of developers giving their feedback and trying to make it as convenient as possible. That was not the case with Apple’s SwiftUI.

Moreover, SwiftUI is strongly tied to a specific version of iOS. Jetpack Compose, however, supports all Android devices down to SDK 21.

And last but not least, with SwiftUI, all the changes are reflected on the preview canvas in real-time without refreshing. Unfortunately, when working with Jetpack compose, you will have to click “refresh” after each change. All in all, both toolkits definitely deserve your attention yet still have room for improvement.

More must-read stories from Enterprise League:

Related Articles