Friday, June 17, 2022

SwiftUI Changes at WWDC 2022

What’s new in SwiftUI:

Join us as we share the latest updates and a glimpse into the future of UI framework design. Discover deep levels of customization, advanced techniques for layout, elegant strategies for sharing, and rock-solid structural approaches for designing an app top-to-bottom in SwiftUI. We’ll also have some celebratory fun as we play with the latest graphical effects and explore APIs.

Bring multiple windows to your SwiftUI app:

Discover how the Shortcuts app uses both SwiftUI and AppKit to create a top-tier experience on macOS. Follow along with the Shortcuts team as we explore how you can host SwiftUI views in AppKit code, handle layout and sizing, participate in the responder chain, enable navigational focus, and more. We’ll also show you how to host AppKit views, helping you migrate existing code into a SwiftUI layout within your app.

Compose custom layouts with SwiftUI:

SwiftUI now offers powerful tools to level up your layouts and arrange views for your app’s interface. We’ll introduce you to the Grid container, which helps you create highly customizable, two-dimensional layouts, and show you how you can use the Layout protocol to build your own containers with completely custom behavior. We’ll also explore how you can create seamless animated transitions between your layout types, and share tips and best practices for creating great interfaces.

The SwiftUI cookbook for navigation:

The recipe for a great app begins with a clear and robust navigation structure. Join the SwiftUI team in our proverbial coding kitchen and learn how you can cook up a great experience for your app. We’ll introduce you to SwiftUI’s navigation stack and split view features, show you how you can link to specific areas of your app, and explore how you can quickly and easily restore navigational state.

Meet Transferable:

Meet Transferable: a model-layer protocol that allows for effortless support for sharing, drag and drop, copy/paste, and other features in your app. We’ll explore how you can use the API for common use cases, and take advantage of advanced features to customize the behavior. We’ll also share how you can optimize for memory efficiency when dealing with large amounts of data. Whether you’re extending your models to share with other applications as strings or images or creating custom declared data types, Transferable can help you facilitate a great experience in your app.

Use SwiftUI with AppKit:

Discover how the Shortcuts app uses both SwiftUI and AppKit to create a top-tier experience on macOS. Follow along with the Shortcuts team as we explore how you can host SwiftUI views in AppKit code, handle layout and sizing, participate in the responder chain, enable navigational focus, and more. We’ll also show you how to host AppKit views, helping you migrate existing code into a SwiftUI layout within your app.

The craft of SwiftUI API design: Progressive disclosure:

Discover the latest SwiftUI APIs to help you present windows within your app’s scenes. We’ll explore how scene types like MenuBarExtra can help you easily build more kinds of apps using SwiftUI. We’ll also show you how to use modifiers that customize the presentation and behavior of your app windows to make even better macOS apps.

Efficiency awaits: Background tasks in SwiftUI:

Background Tasks help apps respond to system events and keep time-sensitive data up to date. Learn how you can use the SwiftUI Background Tasks API to handle tasks succinctly. We’ll show you how to use Swift Concurrency to handle network responses, background refresh, and more — all while preserving performance and power.

• • •

Majid Jabrayilov:

This post will cover the most significant additions and changes to the SwiftUI framework.

Paul Hudson (tweet):

I’ve managed to explore maybe two thirds of the new API, but there’s still more to explore – I’ll update this article soon.

Big Mountain Studio:

A list of everything new in SwiftUI after WWDC 2022.

Natalia Panferova:

SwiftUI has brand new navigation APIs in iOS 16 and macOS 13. They allow us to define stack-based navigation and multicolumn navigation.

Natalia Panferova:

NavigationSplitView accepts a columnVisibility parameter with a value of type NavigationSplitViewVisibility. It lets us specify what columns we would like to show.

In three-column navigation we have control over the sidebar and the middle column and in two-column navigation we can control the sidebar.

In this article we’ll be looking into how to programmatically hide and show the sidebar in two-column navigation.

Majid Jabrayilov:

Navigation was the main pain point of the framework from the very first day. Fortunately, things have changed since WWDC 22, and SwiftUI provides the new data-driven Navigation API. This week we will learn how to use the new Navigation API to build complex user flows.

Kyle Macomber:

From the beginning of SwiftUI we’ve had a vision to not only provide you with great declarative APIs, but also the underlying imperative mechanisms we use to build them.

Imagine having the low-level control to add custom extensions to CSS like a browser engine, to bundle them with your app, and share them in a package.

SwiftUI’s new Layout protocol gives you the full power and flexibility we used to implement SwiftUI’s stacks and grid to build your own first-class layout abstractions.

Swift Talk:

We take a first look at SwiftUI’s new Layout protocol and integrate the flow layout we’ve built previously.

Natalia Panferova:

In iOS 16 SwiftUI introduces a new API to create adaptive layouts ViewThatFits. This API allows us to provide alternative views when a certain view doesn’t fit into available space.

Harlan Haskins:

Layout, Grid, and ViewThatFits obviate the need for the vast majority of GeometryReaders I’ve seen in the wild. Please give them a try, you won’t be disappointed!

Ish Abazz:

I kinda think that common layouts like EqualWidth, EqualHeight, and HorizontalFlow Layouts should be included in SwiftUI. We can build them ourselves with the new Layout protocol, but why have thousands of implementations of the same common layouts?

Joseph Heck:

Oh - this is so nice! ImageRenderer to take a SwiftUI view into either an Image or PDF context through CGContext.

Khoa Pham:

There are over 20 new #SwiftUI EnvironmentValues in iOS 16 #WWDC22 ranging from Controls Input, Widgets, Scrolling and SceneKit categories.

My favorites are requestReview and openWindow

Natalia Panferova:

Starting from iOS 16 and macOS 13 we have a unified native SwiftUI API to request App Store reviews in our apps. We can read requestReview property from the environment and call it as a function at the appropriate time.

Natalia Panferova:

Starting from iOS 16 we can present resizable sheets natively in SwiftUI. In this article we’ll look into what we can achieve with the new APIs and what limitations they have in comparison with UIKit.

Khoa Pham:

In WWDC21, WWDC22 Apple provide a Slack channel for people to interact with Apple engineers in digital lounges. Here I note down some interesting Q&As

Javier:

I have categorized, curated, and in some cases commented the SwiftUI Digital Lounge questions.

Javier:

The following chart shows the number of types that are new, deprecated, or already existed but are now extended to a new platform (e.g., Tables where only available on macOS, but now they can also be used with iOS).

[…]

The following charts show how many types, initializers, methods and properties where added every year[…]

Previously:

Update (2022-06-24): Bardi Golriz (via Dave Verwer):

Not a day goes by when I don’t benefit from the SwiftUI community’s incredibly giving spirit. It was time I gave a little back. So on a Saturday night, I began archiving all questions/answers from its WWDC22 Slack channel. Several hours later, and it was done.

Lucky7 is having problems with Transferable and ShareLink.

Update (2022-06-30): James Dempsey:

There is now a way to handle a double-click on a Table or List in SwiftUI for macOS.

Comments RSS · Twitter

Leave a Comment