diff --git a/Introspect/AppKitIntrospectionView.swift b/Introspect/AppKitIntrospectionView.swift index ae375ff07..02e418ef6 100644 --- a/Introspect/AppKitIntrospectionView.swift +++ b/Introspect/AppKitIntrospectionView.swift @@ -3,6 +3,7 @@ import SwiftUI import AppKit /// Introspection NSView that is inserted alongside the target view. +@available(macOS 15.0, *) public class IntrospectionNSView: NSView { required init() { @@ -22,6 +23,7 @@ public class IntrospectionNSView: NSView { /// Introspection View that is injected into the UIKit hierarchy alongside the target view. /// After `updateNSView` is called, it calls `selector` to find the target view, then `customize` when the target view is found. +@available(macOS 15.0, *) public struct AppKitIntrospectionView: NSViewRepresentable { /// Method that introspects the view hierarchy to find the target view. diff --git a/Introspect/Introspect.swift b/Introspect/Introspect.swift index 80da3781c..e72c32b23 100644 --- a/Introspect/Introspect.swift +++ b/Introspect/Introspect.swift @@ -190,7 +190,7 @@ public enum Introspect { } } -enum TargetViewSelector { +public enum TargetViewSelector { public static func sibling(from entry: PlatformView) -> TargetView? { guard let viewHost = Introspect.findViewHost(from: entry) else { return nil diff --git a/Introspect/UIKitIntrospectionView.swift b/Introspect/UIKitIntrospectionView.swift index e63386646..0a655271f 100644 --- a/Introspect/UIKitIntrospectionView.swift +++ b/Introspect/UIKitIntrospectionView.swift @@ -3,6 +3,7 @@ import UIKit import SwiftUI /// Introspection UIView that is inserted alongside the target view. +@available(iOS 13.0, *) public class IntrospectionUIView: UIView { required init() { @@ -19,6 +20,7 @@ public class IntrospectionUIView: UIView { /// Introspection View that is injected into the UIKit hierarchy alongside the target view. /// After `updateUIView` is called, it calls `selector` to find the target view, then `customize` when the target view is found. +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) public struct UIKitIntrospectionView: UIViewRepresentable { /// Method that introspects the view hierarchy to find the target view. diff --git a/Introspect/UIKitIntrospectionViewController.swift b/Introspect/UIKitIntrospectionViewController.swift index 59ed12b59..8eadf178b 100644 --- a/Introspect/UIKitIntrospectionViewController.swift +++ b/Introspect/UIKitIntrospectionViewController.swift @@ -3,6 +3,7 @@ import SwiftUI import UIKit /// Introspection UIViewController that is inserted alongside the target view controller. +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) public class IntrospectionUIViewController: UIViewController { required init() { super.init(nibName: nil, bundle: nil) @@ -16,6 +17,7 @@ public class IntrospectionUIViewController: UIViewController { } /// This is the same logic as IntrospectionView but for view controllers. Please see details above. +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) public struct UIKitIntrospectionViewController: UIViewControllerRepresentable { let selector: (IntrospectionUIViewController) -> TargetViewControllerType? diff --git a/Introspect/ViewExtensions.swift b/Introspect/ViewExtensions.swift index bbb07bd8a..374e6b7df 100644 --- a/Introspect/ViewExtensions.swift +++ b/Introspect/ViewExtensions.swift @@ -6,6 +6,7 @@ import AppKit import UIKit #endif +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) extension View { public func inject(_ view: SomeView) -> some View where SomeView: View { return overlay(view.frame(width: 0, height: 0)) @@ -13,6 +14,7 @@ extension View { } #if canImport(UIKit) +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) extension View { /// Finds a `TargetView` from a `SwiftUI.View` @@ -115,6 +117,7 @@ extension View { #endif #if canImport(AppKit) && !targetEnvironment(macCatalyst) +@available(macOS 15.0, *) extension View { /// Finds a `TargetView` from a `SwiftUI.View` diff --git a/IntrospectTests/AppKitTests.swift b/IntrospectTests/AppKitTests.swift index ba716b02b..f09175231 100644 --- a/IntrospectTests/AppKitTests.swift +++ b/IntrospectTests/AppKitTests.swift @@ -4,6 +4,7 @@ import XCTest import SwiftUI @testable import Introspect +@available(macOS 15.0, *) enum TestUtils { static func present(view: ViewType) { @@ -18,6 +19,7 @@ enum TestUtils { } } +@available(macOS 15.0, *) private struct ListTestView: View { let spy1: () -> Void @@ -37,6 +39,7 @@ private struct ListTestView: View { } } +@available(macOS 15.0, *) private struct ScrollTestView: View { let spy1: () -> Void @@ -60,6 +63,7 @@ private struct ScrollTestView: View { } } +@available(macOS 15.0, *) private struct TextFieldTestView: View { let spy: () -> Void @State private var textFieldValue = "" @@ -71,6 +75,7 @@ private struct TextFieldTestView: View { } } +@available(macOS 15.0, *) private struct SliderTestView: View { let spy: () -> Void @State private var sliderValue = 0.0 @@ -82,6 +87,7 @@ private struct SliderTestView: View { } } +@available(macOS 15.0, *) private struct StepperTestView: View { let spy: () -> Void var body: some View { @@ -94,6 +100,7 @@ private struct StepperTestView: View { } } +@available(macOS 15.0, *) private struct DatePickerTestView: View { let spy: () -> Void @State private var datePickerValue = Date() @@ -107,6 +114,7 @@ private struct DatePickerTestView: View { } } +@available(macOS 15.0, *) private struct SegmentedControlTestView: View { @State private var pickerValue = 0 let spy: () -> Void @@ -123,6 +131,7 @@ private struct SegmentedControlTestView: View { } } +@available(macOS 15.0, *) class AppKitTests: XCTestCase { func testList() { diff --git a/IntrospectTests/UIKitTests.swift b/IntrospectTests/UIKitTests.swift index a9052f982..625db9897 100644 --- a/IntrospectTests/UIKitTests.swift +++ b/IntrospectTests/UIKitTests.swift @@ -4,6 +4,7 @@ import SwiftUI @testable import Introspect +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) enum TestUtils { static func present(view: ViewType) { @@ -27,6 +28,7 @@ enum TestUtils { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) private struct NavigationTestView: View { let spy: () -> Void var body: some View { @@ -41,6 +43,7 @@ private struct NavigationTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) private struct ViewControllerTestView: View { let spy: () -> Void var body: some View { @@ -55,6 +58,7 @@ private struct ViewControllerTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) private struct NavigationRootTestView: View { let spy: () -> Void var body: some View { @@ -69,6 +73,7 @@ private struct NavigationRootTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) private struct TabTestView: View { @State private var selection = 0 let spy: () -> Void @@ -83,6 +88,7 @@ private struct TabTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) private struct TabRootTestView: View { @State private var selection = 0 let spy: () -> Void @@ -97,6 +103,7 @@ private struct TabRootTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) private struct ListTestView: View { let spy1: () -> Void @@ -116,6 +123,7 @@ private struct ListTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) private struct ScrollTestView: View { let spy1: () -> Void @@ -139,6 +147,7 @@ private struct ScrollTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) private struct TextFieldTestView: View { let spy: () -> Void @State private var textFieldValue = "" @@ -150,6 +159,7 @@ private struct TextFieldTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) @available(tvOS, unavailable) private struct ToggleTestView: View { let spy: () -> Void @@ -162,6 +172,7 @@ private struct ToggleTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) @available(tvOS, unavailable) private struct SliderTestView: View { let spy: () -> Void @@ -174,6 +185,7 @@ private struct SliderTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) @available(tvOS, unavailable) private struct StepperTestView: View { let spy: () -> Void @@ -187,6 +199,7 @@ private struct StepperTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) @available(tvOS, unavailable) private struct DatePickerTestView: View { let spy: () -> Void @@ -201,6 +214,7 @@ private struct DatePickerTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) private struct SegmentedControlTestView: View { @State private var pickerValue = 0 let spy: () -> Void @@ -217,6 +231,7 @@ private struct SegmentedControlTestView: View { } } +@available(iOS 13.0, tvOS 13.0, macOS 15.0, *) class UIKitTests: XCTestCase { func testNavigation() { diff --git a/Package.swift b/Package.swift index c9f72edae..574ee13df 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,9 @@ import PackageDescription let package = Package( name: "Introspect", platforms: [ - .macOS(.v10_15), .iOS(.v13), .tvOS(.v13) + .macOS(.v10_13), + .iOS(.v11), + .tvOS(.v11) ], products: [ .library(