Developing for Apple’s ecosystem can seem daunting. Creating performant apps for iOS, iPadOS, watchOS, macOS, and tvOS can require a lot of resources, planning, and coordination. Plus, each platform has its share of nuances and issues as seen throughout previous years of development. Thankfully, Apple has a vision to make developing for its ecosystem easier, and more developer friendly.
Apple’s approach to streamlining development across its platforms is SwiftUI, which can provide developers with a path for reusable, scalable, and maintainable code that will allow teams to deliver apps in less time than had been possible in previous years.
SwiftUI is now the standard for developing user interfaces for iOS; however, SwiftUI is not just for iOS. It is now the primary framework to develop UIs for all platforms within Apple’s ecosystem. Designs can be shared between iOS, iPadOS, macOS, tvOS, and watchOS with ease and minimal effort.
There is also an opportunity to maximize the reusability of the UI code. With the proper approach to the design and development of apps for multiple platforms, overhead, code, and time can be reduced to deliver these products to the market.
Historically, developing for Apple platforms included words like, “storyboards” or “xibs” (pronounced as “nibs”). These were primarily visual approaches to defining and declaring UI/UX elements within apps.
Developers always had the option to develop their UI with code, but depending on the approach, maintainability and scalability could be an issue.
SwiftUI introduces “declarative syntax” to develop UI. It takes a lot less code to create interfaces, and it is much easier to read and understand how the interface is structured at a glance.
SwiftUI’s declarative syntax can lead to an improvement in scalability and maintainability since the layout code is much less complicated than the previous approach to UI implementation that Apple provided.
With the latest version of Apple development tools (Xcode 11 & macOS Catalina), Developers can create user interfaces with SwiftUI and use the new feature called “preview” to view them as they are built.
What does this mean? Previously when developing user interfaces, a view would be coded, Developers would compile and run the app, then watch the app launch in the simulator. They would finally verify if what was coded was correct. Developers would then rinse and repeat the process.
Thanks to the preview feature, Developers can write view code and have a visual of what they are creating alongside their code. Xcode will automatically update the preview without requiring recompiling (also known as “dynamic replacement”).
This has enormous implications for designers and developers. If you take the component-based approach to develop software (as Intersect does), Developers can create and demonstrate previews to the design team during the development cycle.
All states of components, font scaling, localization, dark mode support, etc., can be previewed without requiring much test data or business logic connections in order to review.
This enables Developers to reduce development time because there is not an immediate requirement to compile and run the app to determine if the design was developed as per the specification.
Developers have the opportunity to use Apple’s native development tools to create multiple apps for the market in parallel.
Using the new SwiftUI framework’s declarative syntax allows for maintainable and scalable code. The ability to preview designs while coding them reduces the development effort since Developers no longer need to run the simulator or device to validate if what was coded was correct.
SwiftUI enables developers to share code across Apple’s ecosystem to deliver apps for iPadOS, watchOS, macOS, and tvOS. Ultimately, using SwiftUI will save time and resources as the process is not as time consuming as it previously was, and will create more cohesive products across Apple’s ecosystem.
Building Custom Views in SwiftUI (WWDC 2019): https://developer.apple.com/videos/play/wwdc2019/237/
Mastering Xcode Previews (WWDC 2019): https://developer.apple.com/videos/play/wwdc2019/233/