Skip to content

What’s new in SwiftUI

Learn what’s new in SwiftUI to build great apps for any Apple platform. We’ll explore how to give your app a brand new look and feel with Liquid Glass. Discover how to boost performance with framework enhancements and new instruments, and integrate advanced capabilities like web content and rich text editing. We’ll also show you how SwiftUI is expanding to more places, including laying out views in three dimensions.

Key Takeaways

  • SwiftUI adopts the new look and feel of the OS out of the box, but provides a variety of tools to customize the behavior.

  • Better interoperability with other frameworks across the board (like AppKit, RealityKit, and WebKit) provides additional flexibility and optionality for advanced use cases and incremental adoption.

  • New views and functionality open SwiftUI to new use cases that previously required bridging, like rich text editing and web views.

Adopt the new design

Toolbars

  • New ToolbarSpacer API to separate buttons.

  • borderedProminent appearance for toolbar items supports tinting via the tint modifier.

Bottom aligned search fields on iOS

  • Use searchable on the outside of the NavigationSplitView to get the bottom aligned search automatically.

  • On iPad, the new search appearance is on the top trailing corner.

  • For tab based apps, you can get the morphing search tab by using the role initializer on your Tab: Tab(role: .search) { … }

Custom views

  • Custom views can adopt the new look too.

  • glassEffect modifier can be applied to reflect the content behind your custom view.

  • Using the commands modifier now yields the same result across iPad and Mac.

Adopt fluid resizing

  • On iPadOS, migrate off APIs that fix the screen to full size.

  • On macOS, for window resizes caused by content size changes, SwiftUI now synchronizes the animation between content and window sizes.

    • Use the new windowResizeAnchor API to customize where the animation originates.

    • Great for animating tab switching in the settings window on macOS.

To learn more about adopting the new design, watch Build a SwiftUI app with the new design.

SwiftUI performance

Key performance improvement areas:

  • Lists

    • Improvements to large lists and incremental updates.

  • Scrolling

    • Improved scheduling for updates on iOS and macOS.

  • Debugging and profiling

New SwiftUI Performance instrument in Xcode

Animatable macro

New @Animatable macro allows you to delete manual custom animatableData property declarations.

You can exclude properties that shouldn’t be animatable as @AnimatableIgnored within your @Animatable annotated type.

@Animatable
struct LoadingArc: Shape {
    var center: CGPoint
    var radius: CGFloat
    var startAngle: Angle
    var endAngle: Angle
    @AnimatableIgnored var drawPathClockwise: Bool
}

SwiftUI on visionOS

More volumetric and spatial layout options.

SwiftUI across the system

Scene bridging

Enhancements to AppKit interoperability

  • You can show sheets in NSWindows with SwiftUI Views in them.

  • AppKit gestures can be bridged to SwiftUI using NSGestureRecognizerRepresentable.

  • NSHostingView can be used in Interface Builder.

Improvements to RealityKit interoperability

  • RealityKit entities now conform to Observable.

    • Makes it trivial to observe changes in SwiftUI views.

  • An improved coordinate conversion API.

  • Enhanced support for presentations right from RealityKit.

Platform adoption

  • Custom Control Center Controls are coming to macOS and watchOS.

  • Widgets are coming to visionOS and CarPlay.

New & updated SwiftUI views

WebView

  • New SwiftUI view for showing web content.

  • Powered by WebKit.

  • Can show URLs or WebPages.

  • WebPage is a new Observable type that enables rich interaction with the web.

  • To learn more about these APIs and the better WebKit interoperability, watch Meet WebKit for SwiftUI.

3D Charts

Drag & Drop

Rich text editing

Missing anything? Corrections? Contributions are welcome!

Written By

philptr
philptr
7 notes contributed