Yesterday, at the ongoing Worldwide Developers Conference (WWDC) 2019, Apple announced a new framework called SwiftUI for building user interfaces across all Apple platforms. With an aim to decrease the line of codes, SwiftUI supports declarative syntax, design tools, and live editing. SwiftUI has an incredible native performance, thus allowing developers to feel fully integrated by taking advantage of the features from the previous technologies and developer experiences of Apple platforms. It’s also automatically supported for dynamic type, dark mode, localization, and accessibility. The tools for SwiftUI development are only available when running on macOS 10.15 beta.
SwiftUI enables a developer to simply state the requirements of a user interface and it will be done directly. For example, if a developer wants a list of items consisting of text fields, then the developer will have to just describe the alignment, font, and color for each field. This makes the code simpler and easier to read, thus saving time and maintenance. SwiftUI also makes complex concepts like animation, much simpler. It enables developers to add animation to almost any control and choose a collection of ready-to-use effects with only a few lines of code.
During the WWDC, Xcode 11 beta release notes were also released. Xcode 11 beta includes SDKs for iOS 13, macOS 10.15, watchOS 6, and tvOS 13. Xcode 11 beta also supports development with SwiftUI. It supports uploading apps from the Organizer window and its editors can now be added to any window without needing an Assistant Editor. Also the LaunchServices on macOS, now respects the selected Xcode when launching Instruments, Simulator, and other developer tools embedded within Xcode. Thus using these intuitive new design tools of Xcode11, SwiftUI can be used to build interfaces like dragging and dropping, dynamic replacement, and previews.
Drag and drop
A developer can arrange components within the user interface by simply dragging controls on the canvas. It can be done by opening an inspector to select font, color, alignment, and other design options, and easily rearrange controls with the cursor. Many of these visual editors are also available within the code editor. It is also possible to drag controls from the library and drop them on the design canvas or directly on the code.
When working in a design canvas, every edit by the developer will be completely in sync with the code in the adjoining editor. Xcode will recompile the changes instantly such that a developer can constantly build an app and run it at the same time, like a ‘live app’. With this feature, Xcode can also swap the edited code directly in the live app.
It is now possible to create one or many previews of any SwiftUI views to get sample data and configure almost anything the users can see, such as large fonts, localizations, or dark mode. The users’ code will be instantly visible as a preview, and if any change is made in the preview, it will immediately appear in the code. Previews can also display a UI, in any device and any orientation.
Native on all Apple platforms
SwiftUI has been created in such a way that all controls and platform-specific experiences are included in the code. It allows an app to directly access the features from the previous technologies of each platform, with a small amount of code and an interactive design canvas. It can be used to build user interfaces for any Apple device, including iPhone, iPad, iPod touch, Apple Watch, and Apple TV.
SwiftUI’s striking features have made developers very excited to try out the framework.
This year was very much the 'future of Apple' year. Watch moving to independence, iPad becoming its own thing, Mac assimilating the iOS ecosystem, and SwiftUI charting Apple's course for the future of app development. So, so many checkboxes were ticked off this year
— Steve Troughton-Smith (@stroughtonsmith) June 3, 2019
— Francisco Jeronimo (@fjeronimo) June 3, 2019
— Sascha Pallenberg (@sascha_p) June 3, 2019
— Matt Gallagher (@cocoawithlove) June 3, 2019
For more details on SwiftUI framework, head over to the Apple Developers website.