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.

Creating a watchOS App

This tutorial gives you a chance to apply much of what you’ve already learned about SwiftUI, and — with little effort — migrate the Landmarks app to watchOS.

AppKit Hosting

protocol NSViewControllerRepresentable

A view that represents an AppKit view controller.

struct NSViewControllerRepresentableContext

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

protocol NSViewRepresentable

A view that represents an AppKit view.

struct NSViewRepresentableContext

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

class NSHostingView

An AppKit view that hosts a SwiftUI view hierarchy.

UIKit Hosting

protocol UIViewRepresentable

A view that represents a UIKit view.

protocol UIViewControllerRepresentable

A view that represents a UIKit view controller.

struct UIViewRepresentableContext

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

struct UIViewControllerRepresentableContext

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

WatchKit Hosting

protocol WKInterfaceObjectRepresentable

A view that represents a WatchKit interface object.

class WKHostingController

A WatchKit interface controller which hosts a SwiftUI view hierarchy.

class WKUserNotificationHostingController

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

struct WKInterfaceObjectRepresentableContext

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

enum DigitalCrownRotationalSensitivity

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

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.