appkit swiftui integration. give me details
Asked on 06/11/2025
1 search
Apple has been enhancing the integration between AppKit and SwiftUI, allowing developers to incrementally adopt SwiftUI in their Mac apps. Here are some key details about this integration:
-
SwiftUI Menus in AppKit: In macOS Sequoia, you can use SwiftUI menus within AppKit contexts using
NSHostingMenu
, a newNSMenu
subclass. This allows you to share menu definitions between parts of your app that use AppKit and those that use SwiftUI. You can create your menu definition using a SwiftUI view and initialize anNSHostingMenu
with it. This is covered in the session What’s new in AppKit. -
Animations: SwiftUI animations can now be used to animate
NSView
in AppKit. This integration allows you to use the full set of powerful SwiftUI animation types, including custom animations, to animate your AppKit views. This is discussed in the session Enhance your UI animations and transitions. -
Gesture Recognition: Gesture recognition has been factored out of UIKit, enabling you to use any built-in or custom UI gesture recognizer in your SwiftUI view hierarchy. This interoperability is crucial for apps that use both SwiftUI and AppKit. More details can be found in the session Platforms State of the Union.
-
View Representables: If there's a view or view controller from AppKit that you want to use in SwiftUI, you can create a view representable. This is a special SwiftUI view protocol for creating and updating an associated AppKit view using imperative code. Conversely, you can embed a SwiftUI view into an AppKit view hierarchy using classes such as
HostingViewController
. This is explained in the session SwiftUI essentials.
These enhancements make it easier to integrate SwiftUI into existing AppKit applications, allowing developers to take advantage of SwiftUI's declarative syntax and powerful features while maintaining compatibility with existing AppKit code.

What’s new in AppKit
Discover the latest advances in Mac app development. Get an overview of the new features in macOS Sequoia, and how to adopt them in your app. Explore new ways to integrate your existing code with SwiftUI. Learn about the improvements made to numerous AppKit controls, like toolbars, menus, text input, and more.

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.

Enhance your UI animations and transitions
Explore how to adopt the zoom transition in navigation and presentations to increase the sense of continuity in your app, and learn how to animate UIKit views with SwiftUI animations to make it easier to build animations that feel continuous.