SwiftUI VS UIKit: the evolution of UI Frameworks for iOS

Pierpaolo Pignelli - 2022-11-10

In this article, we discover the differences and the pros and cons of these two iOS frameworks to help you choose the one best suited to your needs.

SwiftUI vs UIKit? Which iOS framework to choose to develop your Apple App? Let's take a look together in this article at the evolution of the two iOS frameworks, used to build the User Interfaces of applications Apple, but also their differences, pros and cons to consider, before you start writing your code!

It's 2019 and Apple announces a new declarative framework that would allow developers to write the same UIs with less code. It is the birth of SwiftUI, which goes alongside the existing iOS framework: UIKit.

Index

  1. The evolution of iOS user interface frameworks
    1. UIKit: the iOS framework companion to a thousand projectsi
    2. SwiftUI, the new coming of age
  2. Same language, many differences...
    1. SwiftUI vs UIKit which is the best iOS Framework? It depends
  3. What to expect from the future and from Apple

The evolution of iOS user interface frameworks

Let's start with the evolution of the two user interface development frameworks for iOS.

Swift at the time was just under 5 years old, was rapidly rising, still very moldable, and with plenty of room for new integrations, as well as having many constructs modified from version to version; UIKit, its framework for the iOS user interface, had been in use much longer.

So imagine the announcement of SwiftUI on a hot June in the California summer with the crowd at the Apple Worldide Developers Conference (WWDC19) completely open-mouthed, because no one in the audience could have thought of such a surprise!

SwiftUI Presentation at Apple WWDC 2019

"First reaction, shock!" as someone would say.

Yet, 3 years later the two frameworks coexist without stepping on each other's toes., like two diligent roommates, although each has its own peculiarities.

Let's go into more detail and try to better understand the pros and cons of this new treat.

UIKit: the iOS framework companion to a thousand projects

Present as early as iOS 2 (iOS 16 came out a few weeks ago!) and written in Objective-C, predecessor of Swift, UIKit allows you to build and manage graphical user interfaces e event-based.

SwiftUI interface

Source: Apple Developer

UIKit is part of Cocoa Touch, one of the components of the first iOS SDK released in 2008. It contains a collection of HTML components, CSS e JS that make the Apps made recognizable in the Apple style.

SwiftUI, the new coming of age

SwiftUI on the other hand is not afraid of comparison and gives its best, for example when the dev uses iOS 14 or even better iOS 15 as the minimum requirement: this allows for better integrations since its first version on iOS 13 had several limitations, one of them being the absence of spinner or progress bar that were introduced with iOS 14.

SwiftUI interface

Source: Apple Developer

One of the merits much vaunted is that of having Apps with little written code and the fact that you can create cross-platform applications (Mac, iPhone or iPad) with the same code. The desire to add widgets to one's App then makes the use of this framework essential.

Same language, many differences...

But let's see the substantial differences between the two sibling frameworks:

  • programming paradigm: UIKit is a type of imperative framework in fact, we devs have to define what will be on the screen after updates and transactions from one UI state to another. Instead, SwiftUI is reactive in nature: what the user sees is a side effect of the structure View update, it is the system that does what is necessary to update the state and reflect the new state to be displayed.

  • Speed of development: there seems to be a clear difference! SwiftUI, seems to be the fastest horse. This is because you can have a live preview of what we are writing, reducing the number of times we test the App on the device/simulator. There is one thing, however: the youthfulness of SwiftUI can be seen in some corner-cases where the use of UIKit is still necessary. This is possible in the same way it was done between Objective-C and Swift: through a bridge that allowed both to coexist in a project, to "plug" a missing flaw in Swift.

  • Minimum requirements: To be implemented SwiftUI needs as a requirement at least iOS 13, remaining albeit lame with many additions made with later releases, UIKit on the other hand, can also start from lower versions, although I personally advise against going below iOS 11, which has 98 percent device coverage.

  • Documentation: SwiftUI, compared to UIKit, loses some points for documentation and web help (yes stackoverflow, I'm talking about you!), but month after month this gap is being closed thanks to market demand, content creators making tutorials and professionals answering questions.

SwiftUI vs UIKit which is the best iOS Framework? It depends

Actually, as it stands, anyone answering this would be right because the choice depends on how we will use it!

We want the maximum control over how our App should look? Let's choose UIKit.

We want widgets, multi-compatibility and/or high speed development? Let's turn everything over to SwiftUI.

What to expect from the future and from Apple

It is inescapable that the market will slowly push more and more for SwiftUI! It goes without saying that Apple itself will increasingly "gladden" the devs with new additions to make it the new standard for Bitten Apple Apps. I therefore recommend (as I, too, have already been doing for a few months) to start as soon as possible to approach the new framework. 

Until the next article! Also here, on the Ulixe Group blog ;)

Pierpaolo Pignelli

The author of this article, has been working at Ulixe as an iOS developer since 2022. A graduate in Computer and Automation Engineering, he has been interested in IT since his teens and was weaned to the videludic world with a Game Boy Color, yellow. He is a lover of basketball and wellness and is an enthusiastic aspiring environmentalist.

Back to our blog to read Pierpaolo's upcoming articles!


See More Posts

background

Be My Eyes: The AI breakthrough for accessibility

Samuel Capano

background

WWDC 2024: New Libraries for iOS Developers

Pierpaolo Pignelli

background

From Ciphers to Computers: Enigma and the Cryptography Revolution.

Alessandra Bertini

Show more

Ulixe Group S.r.l. Copyright © Ulixe Group S.r.l. | Lungo Dora Pietro Colletta, 67, 10153, Turin, Italy | VAT IT03305250122 | Rea Number TO1173020