Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

Apple releases native SwiftUI framework with declarative syntax, live editing, and support of Xcode 11 beta

Save for later
  • 4 min read
  • 04 Jun 2019

article-image

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.

Declarative syntax


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.

Design tools


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.

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime

Dynamic replacement


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.

Previews


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.

https://twitter.com/stroughtonsmith/status/1135647926439632899

https://twitter.com/fjeronimo/status/1135626395168563201

https://twitter.com/sascha_p/status/1135626257884782592

https://twitter.com/cocoawithlove/status/1135626052678574080

For more details on SwiftUI framework, head over to the Apple Developers website.

Apple promotes app store principles & practices as good for developers and consumers following rising antitrust worthy allegations

Apple proposes a “privacy-focused” ad click attribution model for counting conversions without tracking users

Apple Pay will soon support NFC tags to trigger payments