Apple unveils SwiftUI for UI development in Swift

SwiftUI framework combines a simple Swift syntax and Xcode-integrated tools for building UIs for all Apple platforms

Apple has introduced the SwiftUI framework, a new set of tools and APIs for building user interfaces for any Apple device. Apple describes SwiftUI as a new paradigm for UI development with its Swift language that leverages a simple declarative syntax that makes code easy to write and understand.

SwiftUI provides a way to build interfaces across all Apple platforms, with one set of tools and APIs. The framework works with Xcode design tools to synchronize coding and designing. Support is provided for capabilities such as dynamic type, localization, and accessibility. Built with the Swift language itself, SwiftUI is available in the Xcode 11 beta IDE. Key features of SwiftUI include:

  • A declarative syntax for stating what a UI should do. For example, developers could specify that they want a list of items consisting of text fields, then describe alignment, font, and color for each field. The declarative style applies to concepts such as animation, as well, with developers able to add animation to nearly any control and choose a collection of ready-to-use effects in just a few lines of code. At runtime, the system handles the steps needed to create a smooth environment and deals with interruptions to keep apps stable.
  • Design tools from Xcode 11 provide for drag-and-drop UI building with SwiftUI. Changes to the UI are visible in preview as the developer types. Xcode recompiles changes and puts them into a running version of an app.
  • Developers can build one or many previews of SwiftUI views to get sample data and configure capabilities for users, such as large fonts, localization, or Dark Mode, a color scheme planned for iOS 13.

SwiftUI can be integrated with views from objects from the UIKit, AppKit, or WatchKit frameworks to leverage platform-specific functionality. Instructions for getting started with SwiftUI in Xcode can be found at Apple.com.