<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/UIViewRepresentable",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI19UIViewRepresentableP"
  },
  "title" : "UIViewRepresentable"
}
-->

# UIViewRepresentable

A wrapper for a UIKit view that you use to integrate that view into your
SwiftUI view hierarchy.

```
@MainActor @preconcurrency protocol UIViewRepresentable : View where Self.Body == Never
```

## Overview

Use a [`UIViewRepresentable`](/documentation/SwiftUI/UIViewRepresentable) instance to create and manage a
<doc://com.apple.documentation/documentation/UIKit/UIView> object in your SwiftUI
interface. Adopt this protocol in one of your app’s custom instances, and
use its methods to create, update, and tear down your view. The creation and
update processes parallel the behavior of SwiftUI views, and you use them to
configure your view with your app’s current state information. Use the
teardown process to remove your view cleanly from your SwiftUI. For example,
you might use the teardown process to notify other objects that the view is
disappearing.

To add your view into your SwiftUI interface, create your
[`UIViewRepresentable`](/documentation/SwiftUI/UIViewRepresentable) instance and add it to your SwiftUI interface. The
system calls the methods of your representable instance at appropriate times
to create and update the view. The following example shows the inclusion of
a custom `MyRepresentedCustomView` structure in the view hierarchy.

```
struct ContentView: View {
   var body: some View {
      VStack {
         Text("Global Sales")
         MyRepresentedCustomView()
      }
   }
}
```

The system doesn’t automatically communicate changes occurring within your
view to other parts of your SwiftUI interface. When you want your view to
coordinate with other SwiftUI views, you must provide a
[`Coordinator`](/documentation/SwiftUI/NSViewControllerRepresentable/Coordinator) instance to facilitate those
interactions. For example, you use a coordinator to forward target-action
and delegate messages from your view to any SwiftUI views.

> Warning: SwiftUI fully controls the layout of the UIKit view’s
> <doc://com.apple.documentation/documentation/UIKit/UIView/center>,
> <doc://com.apple.documentation/documentation/UIKit/UIView/bounds>,
> <doc://com.apple.documentation/documentation/UIKit/UIView/frame>, and
> <doc://com.apple.documentation/documentation/UIKit/UIView/transform>
> properties. Don’t directly set these layout-related properties on the view
> managed by a `UIViewRepresentable` instance from your own
> code because that conflicts with SwiftUI and results in undefined behavior.

## Topics

### Creating and updating the view

[`makeUIView(context:)`](/documentation/SwiftUI/UIViewRepresentable/makeUIView(context:))

Creates the view object and configures its initial state.

[`updateUIView(_:context:)`](/documentation/SwiftUI/UIViewRepresentable/updateUIView(_:context:))

Updates the state of the specified view with new information from
SwiftUI.

[`UIViewRepresentable.Context`](/documentation/SwiftUI/UIViewRepresentable/Context)

[`UIViewType`](/documentation/SwiftUI/UIViewRepresentable/UIViewType)

The type of view to present.

### Specifying a size

[`sizeThatFits(_:uiView:context:)`](/documentation/SwiftUI/UIViewRepresentable/sizeThatFits(_:uiView:context:))

Given a proposed size, returns the preferred size of the composite view.

### Cleaning up the view

[`dismantleUIView(_:coordinator:)`](/documentation/SwiftUI/UIViewRepresentable/dismantleUIView(_:coordinator:))

Cleans up the presented UIKit view (and coordinator) in anticipation of
their removal.

### Providing a custom coordinator object

[`makeCoordinator()`](/documentation/SwiftUI/UIViewRepresentable/makeCoordinator())

Creates the custom instance that you use to communicate changes from
your view to other parts of your SwiftUI interface.

[`Coordinator`](/documentation/SwiftUI/UIViewRepresentable/Coordinator)

A type to coordinate with the view.

### Performing layout

[`UIViewRepresentable.LayoutOptions`](/documentation/SwiftUI/UIViewRepresentable/LayoutOptions)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)