Framework Integration

Integrate SwiftUI views into existing apps, and embed AppKit, UIKit, and WatchKit views and controllers into SwiftUI view hierarchies.

Topics

Essentials

Interfacing with UIKit

SwiftUI works seamlessly with the existing UI frameworks on all Apple platforms. For example, you can place UIKit views and view controllers inside SwiftUI views, and vice versa.

AppKit Hosting

protocol NSViewControllerRepresentable

A view that represents an AppKit view controller.

Beta
struct NSViewControllerRepresentableContext

The context in which updates to an associated AppKit view controller take place.

Beta
protocol NSViewRepresentable

A view that represents an AppKit view.

Beta
struct NSViewRepresentableContext

The context in which updates to an associated AppKit view take place.

Beta
class NSHostingView

An AppKit view that hosts a SwiftUI view hierarchy.

Beta

UIKit Hosting

protocol UIViewRepresentable

A view that represents a UIKit view.

Beta
protocol UIViewControllerRepresentable

A view that represents a UIKit view controller.

Beta
struct UIViewRepresentableContext

The context in which updates to an associated UIKit view take place.

Beta
struct UIViewControllerRepresentableContext

The context in which updates to an associated UIKit view controller take place.

Beta

WatchKit Hosting

protocol WKInterfaceObjectRepresentable

A view that represents a WatchKit interface object.

Beta
class WKHostingController

A WatchKit interface controller which hosts a SwiftUI view hierarchy.

Beta
class WKUserNotificationHostingController

A WatchKit user notification interface controller which hosts a SwiftUI view hierarchy.

Beta
struct WKInterfaceObjectRepresentableContext

The context in which updates to an associated WatchKit interface object take place.

Beta
enum DigitalCrownRotationalSensitivity

The amount of Digital Crown rotation needed to move between two integer numbers.

Beta

Deprecated

Deprecated Symbols

Review symbols that are no longer supported, and find the replacements to use instead.

See Also

User Interface

Views and Controls

Present your content onscreen and handle user interactions.

View Layout and Presentation

Combine views in stacks, generate groups and lists of views dynamically, and define view presentations and hierarchy.

Drawing and Animation

Enhance your views with colors, shapes, and shadows, and customize animated transitions between view states.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software