diff --git a/Sources/NSUI/ViewControllerRepresentable.swift b/Sources/NSUI/ViewControllerRepresentable.swift index 52348f2..1d8d63f 100644 --- a/Sources/NSUI/ViewControllerRepresentable.swift +++ b/Sources/NSUI/ViewControllerRepresentable.swift @@ -1,7 +1,7 @@ import SwiftUI #if canImport(AppKit) && !targetEnvironment(macCatalyst) -public protocol NSUIViewControllerRepresentable: NSViewControllerRepresentable { +public protocol NSUIViewControllerRepresentable: NSViewControllerRepresentable where NSViewControllerType == NSUIViewControllerType { associatedtype NSUIViewControllerType: NSUIViewController @MainActor @@ -42,7 +42,7 @@ public extension NSUIViewControllerRepresentable { } #elseif canImport(UIKit) -public protocol NSUIViewControllerRepresentable: UIViewControllerRepresentable { +public protocol NSUIViewControllerRepresentable: UIViewControllerRepresentable where UIViewControllerType == NSUIViewControllerType { associatedtype NSUIViewControllerType: NSUIViewController @MainActor @@ -75,6 +75,7 @@ public extension NSUIViewControllerRepresentable { Self.dismantleNSUIViewController(viewController, coordinator: coordinator) } + @available(iOS 16.0, tvOS 16.0, *) @MainActor func sizeThatFits( _ proposal: ProposedViewSize, diff --git a/Tests/NSUITests/ViewControllerRepresentableTests.swift b/Tests/NSUITests/ViewControllerRepresentableTests.swift index d7ec6b7..5fe3509 100644 --- a/Tests/NSUITests/ViewControllerRepresentableTests.swift +++ b/Tests/NSUITests/ViewControllerRepresentableTests.swift @@ -3,13 +3,11 @@ import NSUI @MainActor struct RepresentedViewController: NSUIViewControllerRepresentable { - typealias NSUIViewControllerType = NSUIViewController - - func makeNSUIViewController(context: Context) -> NSUIViewControllerType { + func makeNSUIViewController(context: Context) -> NSUIViewController { NSUIViewControllerType(nibName: nil, bundle: nil) } - func updateNSUIViewController(_ viewController: NSUIViewControllerType, context: Context) { + func updateNSUIViewController(_ viewController: NSUIViewController, context: Context) { } final class Coordinator {} diff --git a/Tests/NSUITests/ViewRepresentableTests.swift b/Tests/NSUITests/ViewRepresentableTests.swift index 397e9a2..1e42ca4 100644 --- a/Tests/NSUITests/ViewRepresentableTests.swift +++ b/Tests/NSUITests/ViewRepresentableTests.swift @@ -1,10 +1,8 @@ import XCTest -@testable import NSUI +import NSUI @MainActor struct RepresentedView: NSUIViewRepresentable { - typealias NSUIViewType = NSUIView - func makeNSUIView(context: Context) -> NSUIView { NSUIView() }