arrow-left

Back to insights

SwiftUI: Efficient app development on all Apple platforms

SwiftUI: Efficient app development on all Apple platforms

Every iOS developer knows the struggle when developing with UIKit or AppKit. Challenges like version control with storyboards, writing a lot of code for basic features, no live reload during development, learning to work with many frameworks, etc. And don't forget the steep learning curve that iOS development requires. Fortunately, Apple came up with the solution to all these struggles and challenges! That solution is called SwiftUI. But what is SwiftUI and why should you use it?

What is SwiftUI?

Swift UI is a new framework for building User Interfaces (UI) for all Apple platforms. Apple introduced this framework in 2019 and the framework has since evolved into a mature framework. It helps developers build apps more efficiently and quickly. And at the same time, it feels very familiar!

Why should you use it?

One of the biggest advantages of using SwiftUI is that you can quickly develop UIs without a lot of code. This is due to SwiftUI's use of declarative syntax.

In older 'event-driven' frameworks such as UIKit - AppKit - WatchKit, developers had to use an imperative way of programming. In these frameworks, you had to execute a series of instructions based on an event, such as pressing a button or loading a screen. You basically changed the app state and determined how the app operates based on these events. The problem with this is that this way of programming can lead to a lot of code for basic tasks, as you have to keep track of different states.

In declarative syntax, we can tell our apps what they should do and what they should look like in different states, and let the app itself handle how to move between those states. And this syntax feels very familiar to web developers used to working with frameworks like React or Vue.

Benefits of using SwiftUI

These frameworks have proven themselves and done their job in terms of cross-platform development. Many (web) developers are already used to the declarative syntax and use it to build apps on different platforms (e.g. React Native).

This brings us to a second advantage: You can build UIs for all Apple platforms with SwiftUI. You don't need to learn another framework. That reduces the learning curve if you want to develop an app for another Apple platform. And that's not all, you can extend your legacy UIKit or AppKit project with SwiftUI code/views. This makes the transition a lot easier!

The final benefit of SwiftUI is SwiftUI Preview. By default, every SwiftUI View you create has a second instance called SwiftUI Preview. This allows you to preview your component and make real-time changes without building your app.

Swift UI Preview
Swift UI Preview

SwiftUI Limitations

Like any new framework, SwiftUI has its difficulties and limitations.

The first limitation is that not everything you can do with UIKit is available in this framework. Apple improves SwiftUI's APIs and components with every update, but not everything is already available. For example, SwiftUI's text input is very limited compared to UITextField or UIText.

Pixel perfect designs are quite difficult to develop in SwiftUI. Building UIs in a completely different way can sometimes be a challenge. You don't have a stylesheet like in web development, so you have to use modifiers, stacks or built-in components like the spacer to style your app. It takes some experience and trial and error to develop beautiful new UIs.

Another problem for older projects is that you cannot target iOS 12 or lower with your SwiftUI app. This means you need to upgrade your project first before switching to SwiftUI.

Last but not least, best practices do not yet exist. You can find many snippets of code and good documentation online. But there are no best practices on how to structure your project or how to work state management. This is of course a personal preference, but remember that SwiftUI was only released in 2019. The community is embracing it as the future, so it is only a matter of time before best practices are formed.

The future of Apple development?

In conclusion, SwiftUI is a powerful framework that allows you to build apps on all Apple platforms. Despite the limitations of this young framework, the community is already adopting it because of its ease of use. Moreover, SwiftUI improves with every new iOS release, narrowing the gap with UIKit. We can conclude that this framework will be the future of Apple development, so it is worth learning it in your organisation. Within Endare, we will be able to use SwiftUI for all our custom iOS development, for example for Widgets, App Clips or other custom iOS development.

Want to know more about SwiftUI? Apple has great documentation/tutorials on using SwiftUI.

Elevate your Apple app development!

Transform your app development journey. Explore SwiftUI with Endare!

Book a meeting

Discuss your idea directly with one of our experts. Pick a slot that fits your schedule!

Book now