what are the main improvements in SwiftUI between iOS15 and iOS16

Asked on 08/12/2024

1 search

Between iOS 15 and iOS 16, SwiftUI has seen several significant improvements:

  1. Previews and Customizations: Xcode Previews now have a dynamic linking architecture, which uses the same build artifacts for both previews and when you build and run, making the workflow smoother. A new previewable macro allows the use of dynamic properties like state directly in an Xcode preview, reducing the amount of code needed.

  2. Graphics Capabilities: SwiftUI introduced a new mix modifier on color, allowing colors to blend beautifully. The custom shader feature has been extended to precompile shaders before their first use, avoiding frame drops.

  3. Scrolling Enhancements: New APIs provide fine-grained control over scroll views, allowing deeper integration with the state of a scroll view. This includes reacting to changes in content offsets and sizes, and detecting when a view's visibility changes due to scrolling.

  4. Interoperability: Gesture recognition has been factored out of UIKit, enabling the use of built-in or custom UI gesture recognizers in SwiftUI view hierarchies. Animations have also been factored out, allowing animations to be set up on UIKit or AppKit views and driven with SwiftUI, including custom animations.

  5. Swift 6 Language Mode: SwiftUI views are now implicitly isolated to the main actor by default, simplifying code by removing the need for explicit main actor annotations.

  6. New APIs and Features: SwiftUI has introduced custom containers, mesh gradients, and more options for customizing window behavior and styling in macOS.

For more detailed information, you can refer to the session What’s new in SwiftUI (16:18) which covers scrolling enhancements and other framework foundations.