diff --git a/.editorconfig b/.editorconfig index cc4a6d55..bd0f2a82 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,8 +2,7 @@ root = true [*] -indent_style = space -indent_size = 4 +indent_style = tab trim_trailing_whitespace = true insert_final_newline = true end_of_line = lf diff --git a/Examples/Showcase/Showcase/App.swift b/Examples/Showcase/Showcase/App.swift index 3c4b836a..e5553b90 100644 --- a/Examples/Showcase/Showcase/App.swift +++ b/Examples/Showcase/Showcase/App.swift @@ -2,13 +2,13 @@ import SwiftUI @main struct App: SwiftUI.App { - var body: some Scene { - WindowGroup { - AppView() - } - } + var body: some Scene { + WindowGroup { + AppView() + } + } } #Preview { - AppView() + AppView() } diff --git a/Examples/Showcase/Showcase/AppView.swift b/Examples/Showcase/Showcase/AppView.swift index df4251c2..9efd0bfc 100644 --- a/Examples/Showcase/Showcase/AppView.swift +++ b/Examples/Showcase/Showcase/AppView.swift @@ -2,69 +2,69 @@ import SwiftUI import SwiftUIIntrospect struct AppView: View { - var body: some View { - ContentView() - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect( - .window, - on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { window in - window.backgroundColor = .brown - } - #elseif os(macOS) - .introspect(.window, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { window in - window.backgroundColor = .lightGray - } - #endif - } + var body: some View { + ContentView() + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect( + .window, + on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { window in + window.backgroundColor = .brown + } + #elseif os(macOS) + .introspect(.window, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { window in + window.backgroundColor = .lightGray + } + #endif + } } struct ContentView: View { - @State var selection = 0 + @State var selection = 0 - var body: some View { - TabView(selection: $selection) { - ListShowcase() - .tabItem { Label("List", systemImage: "1.circle") } - .tag(0) - ScrollViewShowcase() - .tabItem { Label("ScrollView", systemImage: "2.circle") } - .tag(1) - #if !os(macOS) - NavigationShowcase() - .tabItem { Label("Navigation", systemImage: "3.circle") } - .tag(2) - PresentationShowcase() - .tabItem { Label("Presentation", systemImage: "4.circle") } - .tag(3) - #endif - ControlsShowcase() - .tabItem { Label("Controls", systemImage: "5.circle") } - .tag(4) - UIViewRepresentableShowcase() - .tabItem { Label("UIViewRepresentable", systemImage: "6.circle") } - .tag(5) - } - #if os(iOS) || os(tvOS) - .introspect(.tabView, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26)) { tabBarController in - if #available(iOS 26, macOS 26, tvOS 26, *) { - tabBarController.tabBar.backgroundColor = .green - } else { - let appearance = UITabBarAppearance() - appearance.configureWithOpaqueBackground() - appearance.backgroundColor = .green - tabBarController.tabBar.standardAppearance = appearance - tabBarController.tabBar.scrollEdgeAppearance = appearance - } - } - #elseif os(macOS) - .introspect(.tabView, on: .macOS(.v12, .v13, .v14)) { splitView in - splitView.subviews.first?.layer?.backgroundColor = NSColor.green.cgColor - } - #endif - } + var body: some View { + TabView(selection: $selection) { + ListShowcase() + .tabItem { Label("List", systemImage: "1.circle") } + .tag(0) + ScrollViewShowcase() + .tabItem { Label("ScrollView", systemImage: "2.circle") } + .tag(1) + #if !os(macOS) + NavigationShowcase() + .tabItem { Label("Navigation", systemImage: "3.circle") } + .tag(2) + PresentationShowcase() + .tabItem { Label("Presentation", systemImage: "4.circle") } + .tag(3) + #endif + ControlsShowcase() + .tabItem { Label("Controls", systemImage: "5.circle") } + .tag(4) + UIViewRepresentableShowcase() + .tabItem { Label("UIViewRepresentable", systemImage: "6.circle") } + .tag(5) + } + #if os(iOS) || os(tvOS) + .introspect(.tabView, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26)) { tabBarController in + if #available(iOS 26, macOS 26, tvOS 26, *) { + tabBarController.tabBar.backgroundColor = .green + } else { + let appearance = UITabBarAppearance() + appearance.configureWithOpaqueBackground() + appearance.backgroundColor = .green + tabBarController.tabBar.standardAppearance = appearance + tabBarController.tabBar.scrollEdgeAppearance = appearance + } + } + #elseif os(macOS) + .introspect(.tabView, on: .macOS(.v12, .v13, .v14)) { splitView in + splitView.subviews.first?.layer?.backgroundColor = NSColor.green.cgColor + } + #endif + } } #Preview { - AppView() + AppView() } diff --git a/Examples/Showcase/Showcase/Controls.swift b/Examples/Showcase/Showcase/Controls.swift index 1a8ec5c1..cc0191f0 100644 --- a/Examples/Showcase/Showcase/Controls.swift +++ b/Examples/Showcase/Showcase/Controls.swift @@ -3,167 +3,167 @@ import SwiftUIIntrospect struct ControlsShowcase: View { - @State private var textFieldValue = "" - @State private var toggleValue = false - @State private var sliderValue = 0.0 - @State private var datePickerValue = Date() - @State private var segmentedControlValue = 0 + @State private var textFieldValue = "" + @State private var toggleValue = false + @State private var sliderValue = 0.0 + @State private var datePickerValue = Date() + @State private var segmentedControlValue = 0 - var body: some View { - VStack { - HStack { - TextField("Text Field Red", text: $textFieldValue) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect( - .textField, - on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { textField in - textField.backgroundColor = .red - } - #elseif os(macOS) - .introspect(.textField, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { textField in - textField.backgroundColor = .red - } - #endif + var body: some View { + VStack { + HStack { + TextField("Text Field Red", text: $textFieldValue) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect( + .textField, + on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { textField in + textField.backgroundColor = .red + } + #elseif os(macOS) + .introspect(.textField, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { textField in + textField.backgroundColor = .red + } + #endif - TextField("Text Field Green", text: $textFieldValue) - .cornerRadius(8) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect( - .textField, - on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { textField in - textField.backgroundColor = .green - } - #elseif os(macOS) - .introspect(.textField, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { textField in - textField.backgroundColor = .green - } - #endif - } + TextField("Text Field Green", text: $textFieldValue) + .cornerRadius(8) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect( + .textField, + on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { textField in + textField.backgroundColor = .green + } + #elseif os(macOS) + .introspect(.textField, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { textField in + textField.backgroundColor = .green + } + #endif + } - #if !os(tvOS) - #if !os(visionOS) - HStack { - Toggle("Toggle Red", isOn: $toggleValue) - #if os(iOS) - .introspect( - .toggle, - on: .iOS(.v15, .v16, .v17, .v18, .v26) - ) { toggle in - toggle.backgroundColor = .red - } - #elseif os(macOS) - .introspect(.toggle, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { toggle in - toggle.layer?.backgroundColor = NSColor.red.cgColor - } - #endif + #if !os(tvOS) + #if !os(visionOS) + HStack { + Toggle("Toggle Red", isOn: $toggleValue) + #if os(iOS) + .introspect( + .toggle, + on: .iOS(.v15, .v16, .v17, .v18, .v26) + ) { toggle in + toggle.backgroundColor = .red + } + #elseif os(macOS) + .introspect(.toggle, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { toggle in + toggle.layer?.backgroundColor = NSColor.red.cgColor + } + #endif - Toggle("Toggle Green", isOn: $toggleValue) - #if os(iOS) - .introspect( - .toggle, - on: .iOS(.v15, .v16, .v17, .v18, .v26) - ) { toggle in - toggle.backgroundColor = .green - } - #elseif os(macOS) - .introspect(.toggle, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { toggle in - toggle.layer?.backgroundColor = NSColor.green.cgColor - } - #endif - } + Toggle("Toggle Green", isOn: $toggleValue) + #if os(iOS) + .introspect( + .toggle, + on: .iOS(.v15, .v16, .v17, .v18, .v26) + ) { toggle in + toggle.backgroundColor = .green + } + #elseif os(macOS) + .introspect(.toggle, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { toggle in + toggle.layer?.backgroundColor = NSColor.green.cgColor + } + #endif + } - HStack { - Slider(value: $sliderValue, in: 0...100) - #if os(iOS) - .introspect(.slider, on: .iOS(.v15, .v16, .v17, .v18, .v26)) { slider in - slider.backgroundColor = .red - } - #elseif os(macOS) - .introspect(.slider, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { slider in - slider.layer?.backgroundColor = NSColor.red.cgColor - } - #endif + HStack { + Slider(value: $sliderValue, in: 0...100) + #if os(iOS) + .introspect(.slider, on: .iOS(.v15, .v16, .v17, .v18, .v26)) { slider in + slider.backgroundColor = .red + } + #elseif os(macOS) + .introspect(.slider, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { slider in + slider.layer?.backgroundColor = NSColor.red.cgColor + } + #endif - Slider(value: $sliderValue, in: 0...100) - #if os(iOS) - .introspect(.slider, on: .iOS(.v15, .v16, .v17, .v18, .v26)) { slider in - slider.backgroundColor = .green - } - #elseif os(macOS) - .introspect(.slider, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { slider in - slider.layer?.backgroundColor = NSColor.green.cgColor - } - #endif - } + Slider(value: $sliderValue, in: 0...100) + #if os(iOS) + .introspect(.slider, on: .iOS(.v15, .v16, .v17, .v18, .v26)) { slider in + slider.backgroundColor = .green + } + #elseif os(macOS) + .introspect(.slider, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { slider in + slider.layer?.backgroundColor = NSColor.green.cgColor + } + #endif + } - HStack { - Stepper(onIncrement: {}, onDecrement: {}) { - Text("Stepper Red") - } - #if os(iOS) - .introspect(.stepper, on: .iOS(.v15, .v16, .v17, .v18, .v26)) { stepper in - stepper.backgroundColor = .red - } - #elseif os(macOS) - .introspect(.stepper, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { stepper in - stepper.layer?.backgroundColor = NSColor.red.cgColor - } - #endif + HStack { + Stepper(onIncrement: {}, onDecrement: {}) { + Text("Stepper Red") + } + #if os(iOS) + .introspect(.stepper, on: .iOS(.v15, .v16, .v17, .v18, .v26)) { stepper in + stepper.backgroundColor = .red + } + #elseif os(macOS) + .introspect(.stepper, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { stepper in + stepper.layer?.backgroundColor = NSColor.red.cgColor + } + #endif - Stepper(onIncrement: {}, onDecrement: {}) { - Text("Stepper Green") - } - #if os(iOS) - .introspect(.stepper, on: .iOS(.v15, .v16, .v17, .v18, .v26)) { stepper in - stepper.backgroundColor = .green - } - #elseif os(macOS) - .introspect(.stepper, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { stepper in - stepper.layer?.backgroundColor = NSColor.green.cgColor - } - #endif - } - #endif + Stepper(onIncrement: {}, onDecrement: {}) { + Text("Stepper Green") + } + #if os(iOS) + .introspect(.stepper, on: .iOS(.v15, .v16, .v17, .v18, .v26)) { stepper in + stepper.backgroundColor = .green + } + #elseif os(macOS) + .introspect(.stepper, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { stepper in + stepper.layer?.backgroundColor = NSColor.green.cgColor + } + #endif + } + #endif - HStack { - DatePicker(selection: $datePickerValue) { - Text("DatePicker Red") - } - #if os(iOS) || os(visionOS) - .introspect(.datePicker, on: .iOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)) { datePicker in - datePicker.backgroundColor = .red - } - #elseif os(macOS) - .introspect(.datePicker, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { datePicker in - datePicker.layer?.backgroundColor = NSColor.red.cgColor - } - #endif - } - #endif + HStack { + DatePicker(selection: $datePickerValue) { + Text("DatePicker Red") + } + #if os(iOS) || os(visionOS) + .introspect(.datePicker, on: .iOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)) { datePicker in + datePicker.backgroundColor = .red + } + #elseif os(macOS) + .introspect(.datePicker, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { datePicker in + datePicker.layer?.backgroundColor = NSColor.red.cgColor + } + #endif + } + #endif - HStack { - Picker(selection: $segmentedControlValue, label: Text("Segmented control")) { - Text("Option 1").tag(0) - Text("Option 2").tag(1) - Text("Option 3").tag(2) - } - .pickerStyle(SegmentedPickerStyle()) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect( - .picker(style: .segmented), - on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { datePicker in - datePicker.backgroundColor = .red - } - #elseif os(macOS) - .introspect(.picker(style: .segmented), on: .macOS(.v12, .v13, .v14, .v15, .v26)) { datePicker in - datePicker.layer?.backgroundColor = NSColor.red.cgColor - } - #endif - } - } + HStack { + Picker(selection: $segmentedControlValue, label: Text("Segmented control")) { + Text("Option 1").tag(0) + Text("Option 2").tag(1) + Text("Option 3").tag(2) + } + .pickerStyle(SegmentedPickerStyle()) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect( + .picker(style: .segmented), + on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { datePicker in + datePicker.backgroundColor = .red + } + #elseif os(macOS) + .introspect(.picker(style: .segmented), on: .macOS(.v12, .v13, .v14, .v15, .v26)) { datePicker in + datePicker.layer?.backgroundColor = NSColor.red.cgColor + } + #endif + } + } - } + } } diff --git a/Examples/Showcase/Showcase/Helpers.swift b/Examples/Showcase/Showcase/Helpers.swift index ae85f5c1..9c9ce479 100644 --- a/Examples/Showcase/Showcase/Helpers.swift +++ b/Examples/Showcase/Showcase/Helpers.swift @@ -1,17 +1,17 @@ import SwiftUI extension View { - /// Modify a view with a `ViewBuilder` closure. - /// - /// This represents a streamlining of the - /// [`modifier`](https://developer.apple.com/documentation/swiftui/view/modifier(_:)) + - /// [`ViewModifier`](https://developer.apple.com/documentation/swiftui/viewmodifier) pattern. - /// - /// - Note: Useful only when you don't need to reuse the closure. - /// If you do, turn the closure into a proper modifier. - public func modifier( - @ViewBuilder _ modifier: (Self) -> ModifiedContent - ) -> ModifiedContent { - modifier(self) - } + /// Modify a view with a `ViewBuilder` closure. + /// + /// This represents a streamlining of the + /// [`modifier`](https://developer.apple.com/documentation/swiftui/view/modifier(_:)) + + /// [`ViewModifier`](https://developer.apple.com/documentation/swiftui/viewmodifier) pattern. + /// + /// - Note: Useful only when you don't need to reuse the closure. + /// If you do, turn the closure into a proper modifier. + public func modifier( + @ViewBuilder _ modifier: (Self) -> ModifiedContent + ) -> ModifiedContent { + modifier(self) + } } diff --git a/Examples/Showcase/Showcase/List.swift b/Examples/Showcase/Showcase/List.swift index 40887766..9d226268 100644 --- a/Examples/Showcase/Showcase/List.swift +++ b/Examples/Showcase/Showcase/List.swift @@ -2,108 +2,108 @@ import SwiftUI import SwiftUIIntrospect struct ListShowcase: View { - @State var receiverListFound: Bool = false - @State var ancestorListFound: Bool = false + @State var receiverListFound: Bool = false + @State var ancestorListFound: Bool = false - var body: some View { - VStack(spacing: 40) { - VStack { - Text("Default") - .lineLimit(1) - .minimumScaleFactor(0.5) - .padding(.horizontal, 12) - List { - Text("Item 1") - Text("Item 2") - } - } + var body: some View { + VStack(spacing: 40) { + VStack { + Text("Default") + .lineLimit(1) + .minimumScaleFactor(0.5) + .padding(.horizontal, 12) + List { + Text("Item 1") + Text("Item 2") + } + } - VStack { - Text(".introspect(.list, ...)") - .lineLimit(1) - .minimumScaleFactor(0.5) - .padding(.horizontal, 12) - .font(.system(.subheadline, design: .monospaced)) - List { - Text("Item 1") - Text("Item 2") - } - .modifier { list in - if #available(iOS 16, macOS 13, *) { - list.background { - if receiverListFound { - Color(.cyan) - } - } - #if !os(tvOS) - .scrollContentBackground(.hidden) - #endif - } else { - list - } - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.list, on: .iOS(.v15), .tvOS(.v15, .v16, .v17, .v18, .v26)) { tableView in - tableView.backgroundView = UIView() - tableView.backgroundColor = .cyan - } - .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)) { collectionView in - DispatchQueue.main.async { - receiverListFound = true - } - } - #elseif os(macOS) - .introspect(.list, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { tableView in - DispatchQueue.main.async { - receiverListFound = true - } - } - #endif - } + VStack { + Text(".introspect(.list, ...)") + .lineLimit(1) + .minimumScaleFactor(0.5) + .padding(.horizontal, 12) + .font(.system(.subheadline, design: .monospaced)) + List { + Text("Item 1") + Text("Item 2") + } + .modifier { list in + if #available(iOS 16, macOS 13, *) { + list.background { + if receiverListFound { + Color(.cyan) + } + } + #if !os(tvOS) + .scrollContentBackground(.hidden) + #endif + } else { + list + } + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.list, on: .iOS(.v15), .tvOS(.v15, .v16, .v17, .v18, .v26)) { tableView in + tableView.backgroundView = UIView() + tableView.backgroundColor = .cyan + } + .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)) { collectionView in + DispatchQueue.main.async { + receiverListFound = true + } + } + #elseif os(macOS) + .introspect(.list, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { tableView in + DispatchQueue.main.async { + receiverListFound = true + } + } + #endif + } - VStack { - Text(".introspect(.list, ..., scope: .ancestor)") - .lineLimit(1) - .minimumScaleFactor(0.5) - .padding(.horizontal, 12) - .font(.system(.subheadline, design: .monospaced)) - List { - Text("Item 1") - Text("Item 2") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.list, on: .iOS(.v15), .tvOS(.v15, .v16, .v17, .v18, .v26), scope: .ancestor) { tableView in - tableView.backgroundView = UIView() - tableView.backgroundColor = .cyan - } - .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor) { collectionView in - DispatchQueue.main.async { - ancestorListFound = true - } - } - #elseif os(macOS) - .introspect(.list, on: .macOS(.v12, .v13, .v14, .v15, .v26), scope: .ancestor) { tableView in - DispatchQueue.main.async { - ancestorListFound = true - } - } - #endif - } - .modifier { list in - if #available(iOS 16, macOS 13, *) { - list.background { - if ancestorListFound { - Color(.cyan) - } - } - #if !os(tvOS) - .scrollContentBackground(.hidden) - #endif - } else { - list - } - } - } - } + VStack { + Text(".introspect(.list, ..., scope: .ancestor)") + .lineLimit(1) + .minimumScaleFactor(0.5) + .padding(.horizontal, 12) + .font(.system(.subheadline, design: .monospaced)) + List { + Text("Item 1") + Text("Item 2") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.list, on: .iOS(.v15), .tvOS(.v15, .v16, .v17, .v18, .v26), scope: .ancestor) { tableView in + tableView.backgroundView = UIView() + tableView.backgroundColor = .cyan + } + .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor) { collectionView in + DispatchQueue.main.async { + ancestorListFound = true + } + } + #elseif os(macOS) + .introspect(.list, on: .macOS(.v12, .v13, .v14, .v15, .v26), scope: .ancestor) { tableView in + DispatchQueue.main.async { + ancestorListFound = true + } + } + #endif + } + .modifier { list in + if #available(iOS 16, macOS 13, *) { + list.background { + if ancestorListFound { + Color(.cyan) + } + } + #if !os(tvOS) + .scrollContentBackground(.hidden) + #endif + } else { + list + } + } + } + } - } + } } diff --git a/Examples/Showcase/Showcase/Navigation.swift b/Examples/Showcase/Showcase/Navigation.swift index 20dab1c3..359c9b0d 100644 --- a/Examples/Showcase/Showcase/Navigation.swift +++ b/Examples/Showcase/Showcase/Navigation.swift @@ -2,45 +2,45 @@ import SwiftUI import SwiftUIIntrospect struct NavigationShowcase: View { - var body: some View { - NavigationView { - Text("Content") - .searchable(text: .constant("")) - #if os(iOS) || os(visionOS) - .navigationBarTitle(Text("Customized"), displayMode: .inline) - #elseif os(macOS) - .navigationTitle(Text("Navigation")) - #endif - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect( - .navigationView(style: .stack), - on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { navigationController in - navigationController.navigationBar.backgroundColor = .cyan - } - .introspect( - .navigationView(style: .columns), - on: .iOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { splitViewController in - #if os(visionOS) - splitViewController.preferredDisplayMode = .oneBesideSecondary - #else - splitViewController.preferredDisplayMode = .oneOverSecondary - #endif - } - .introspect(.navigationView(style: .columns), on: .tvOS(.v15, .v16, .v17, .v18, .v26)) { navigationController in - navigationController.navigationBar.backgroundColor = .cyan - } - .introspect( - .searchField, - on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { searchBar in - searchBar.backgroundColor = .red - #if os(iOS) - searchBar.searchTextField.backgroundColor = .purple - #endif - } - #endif - } + var body: some View { + NavigationView { + Text("Content") + .searchable(text: .constant("")) + #if os(iOS) || os(visionOS) + .navigationBarTitle(Text("Customized"), displayMode: .inline) + #elseif os(macOS) + .navigationTitle(Text("Navigation")) + #endif + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect( + .navigationView(style: .stack), + on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { navigationController in + navigationController.navigationBar.backgroundColor = .cyan + } + .introspect( + .navigationView(style: .columns), + on: .iOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { splitViewController in + #if os(visionOS) + splitViewController.preferredDisplayMode = .oneBesideSecondary + #else + splitViewController.preferredDisplayMode = .oneOverSecondary + #endif + } + .introspect(.navigationView(style: .columns), on: .tvOS(.v15, .v16, .v17, .v18, .v26)) { navigationController in + navigationController.navigationBar.backgroundColor = .cyan + } + .introspect( + .searchField, + on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { searchBar in + searchBar.backgroundColor = .red + #if os(iOS) + searchBar.searchTextField.backgroundColor = .purple + #endif + } + #endif + } } diff --git a/Examples/Showcase/Showcase/Presentation.swift b/Examples/Showcase/Showcase/Presentation.swift index db830197..db96a9c3 100644 --- a/Examples/Showcase/Showcase/Presentation.swift +++ b/Examples/Showcase/Showcase/Presentation.swift @@ -3,56 +3,56 @@ import SwiftUIIntrospect #if !os(macOS) struct PresentationShowcase: View { - @State var isSheetPresented = false - @State var isFullScreenPresented = false - @State var isPopoverPresented = false + @State var isSheetPresented = false + @State var isFullScreenPresented = false + @State var isPopoverPresented = false - var body: some View { - VStack(spacing: 20) { - Button("Sheet", action: { isSheetPresented = true }) - .sheet(isPresented: $isSheetPresented) { - Button("Dismiss", action: { isSheetPresented = false }) - #if os(iOS) || os(tvOS) - .introspect( - .sheet, - on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26) - ) { presentationController in - presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75) - } - #elseif os(visionOS) - .introspect(.sheet, on: .visionOS(.v1, .v2, .v26)) { sheetPresentationController in - sheetPresentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75) - } - #endif - } + var body: some View { + VStack(spacing: 20) { + Button("Sheet", action: { isSheetPresented = true }) + .sheet(isPresented: $isSheetPresented) { + Button("Dismiss", action: { isSheetPresented = false }) + #if os(iOS) || os(tvOS) + .introspect( + .sheet, + on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26) + ) { presentationController in + presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75) + } + #elseif os(visionOS) + .introspect(.sheet, on: .visionOS(.v1, .v2, .v26)) { sheetPresentationController in + sheetPresentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75) + } + #endif + } - Button("Full Screen Cover", action: { isFullScreenPresented = true }) - .fullScreenCover(isPresented: $isFullScreenPresented) { - Button("Dismiss", action: { isFullScreenPresented = false }) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect( - .fullScreenCover, - on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { presentationController in - presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75) - } - #endif - } + Button("Full Screen Cover", action: { isFullScreenPresented = true }) + .fullScreenCover(isPresented: $isFullScreenPresented) { + Button("Dismiss", action: { isFullScreenPresented = false }) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect( + .fullScreenCover, + on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { presentationController in + presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75) + } + #endif + } - #if os(iOS) || os(visionOS) - Button("Popover", action: { isPopoverPresented = true }) - .popover(isPresented: $isPopoverPresented) { - Button("Dismiss", action: { isPopoverPresented = false }) - .padding() - .introspect( - .popover, - on: .iOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { presentationController in - presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75) - } - } - #endif - } - } + #if os(iOS) || os(visionOS) + Button("Popover", action: { isPopoverPresented = true }) + .popover(isPresented: $isPopoverPresented) { + Button("Dismiss", action: { isPopoverPresented = false }) + .padding() + .introspect( + .popover, + on: .iOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { presentationController in + presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75) + } + } + #endif + } + } } #endif diff --git a/Examples/Showcase/Showcase/ScrollView.swift b/Examples/Showcase/Showcase/ScrollView.swift index 185ba955..eb31a44c 100644 --- a/Examples/Showcase/Showcase/ScrollView.swift +++ b/Examples/Showcase/Showcase/ScrollView.swift @@ -2,79 +2,79 @@ import SwiftUI import SwiftUIIntrospect struct ScrollViewShowcase: View { - @State var receiverScrollViewFound: Bool = false - @State var ancestorScrollViewFound: Bool = false + @State var receiverScrollViewFound: Bool = false + @State var ancestorScrollViewFound: Bool = false - var body: some View { - VStack(spacing: 40) { - ScrollView { - Text("Default") - .frame(maxWidth: .infinity) - .lineLimit(1) - .minimumScaleFactor(0.5) - .padding(.horizontal, 12) - } + var body: some View { + VStack(spacing: 40) { + ScrollView { + Text("Default") + .frame(maxWidth: .infinity) + .lineLimit(1) + .minimumScaleFactor(0.5) + .padding(.horizontal, 12) + } - ScrollView { - Text(".introspect(.scrollView, ...)") - .frame(maxWidth: .infinity) - .lineLimit(1) - .minimumScaleFactor(0.5) - .padding(.horizontal, 12) - .font(.system(.subheadline, design: .monospaced)) - } - .background { - if receiverScrollViewFound { - Color(.cyan) - } - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect( - .scrollView, - on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { _ in - DispatchQueue.main.async { - receiverScrollViewFound = true - } - } - #elseif os(macOS) - .introspect(.scrollView, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { scrollView in - DispatchQueue.main.async { - receiverScrollViewFound = true - } - } - #endif + ScrollView { + Text(".introspect(.scrollView, ...)") + .frame(maxWidth: .infinity) + .lineLimit(1) + .minimumScaleFactor(0.5) + .padding(.horizontal, 12) + .font(.system(.subheadline, design: .monospaced)) + } + .background { + if receiverScrollViewFound { + Color(.cyan) + } + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect( + .scrollView, + on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { _ in + DispatchQueue.main.async { + receiverScrollViewFound = true + } + } + #elseif os(macOS) + .introspect(.scrollView, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { scrollView in + DispatchQueue.main.async { + receiverScrollViewFound = true + } + } + #endif - ScrollView { - Text(".introspect(.scrollView, ..., scope: .ancestor)") - .frame(maxWidth: .infinity) - .lineLimit(1) - .minimumScaleFactor(0.5) - .padding(.horizontal, 12) - .font(.system(.subheadline, design: .monospaced)) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect( - .scrollView, - on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), - scope: .ancestor - ) { _ in - DispatchQueue.main.async { - ancestorScrollViewFound = true - } - } - #elseif os(macOS) - .introspect(.scrollView, on: .macOS(.v12, .v13, .v14, .v15, .v26), scope: .ancestor) { scrollView in - DispatchQueue.main.async { - ancestorScrollViewFound = true - } - } - #endif - } - .background { - if ancestorScrollViewFound { - Color(.cyan) - } - } - } - } + ScrollView { + Text(".introspect(.scrollView, ..., scope: .ancestor)") + .frame(maxWidth: .infinity) + .lineLimit(1) + .minimumScaleFactor(0.5) + .padding(.horizontal, 12) + .font(.system(.subheadline, design: .monospaced)) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect( + .scrollView, + on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), + scope: .ancestor + ) { _ in + DispatchQueue.main.async { + ancestorScrollViewFound = true + } + } + #elseif os(macOS) + .introspect(.scrollView, on: .macOS(.v12, .v13, .v14, .v15, .v26), scope: .ancestor) { scrollView in + DispatchQueue.main.async { + ancestorScrollViewFound = true + } + } + #endif + } + .background { + if ancestorScrollViewFound { + Color(.cyan) + } + } + } + } } diff --git a/Examples/Showcase/Showcase/UIViewRepresentable.swift b/Examples/Showcase/Showcase/UIViewRepresentable.swift index 54bff09b..a3cd932c 100644 --- a/Examples/Showcase/Showcase/UIViewRepresentable.swift +++ b/Examples/Showcase/Showcase/UIViewRepresentable.swift @@ -2,70 +2,70 @@ import SwiftUI @_spi(Internals) import SwiftUIIntrospect struct UIViewRepresentableShowcase: View { - let colors: [Color] = [.red, .green, .blue] + let colors: [Color] = [.red, .green, .blue] - var body: some View { - VStack(spacing: 10) { - ForEach(colors, id: \.self) { color in - GenericViewRepresentable() - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect( - .view, - on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { view in - view.backgroundColor = UIColor(color) - } - #elseif os(macOS) - .introspect(.view, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { view in - view.layer?.backgroundColor = NSColor(color).cgColor - } - #endif - } - } - .padding() - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect( - .view, - on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { view in - view.backgroundColor = .red - } - #elseif os(macOS) - .introspect(.view, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { view in - view.layer?.backgroundColor = NSColor.red.cgColor - } - #endif - } + var body: some View { + VStack(spacing: 10) { + ForEach(colors, id: \.self) { color in + GenericViewRepresentable() + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect( + .view, + on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { view in + view.backgroundColor = UIColor(color) + } + #elseif os(macOS) + .introspect(.view, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { view in + view.layer?.backgroundColor = NSColor(color).cgColor + } + #endif + } + } + .padding() + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect( + .view, + on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { view in + view.backgroundColor = .red + } + #elseif os(macOS) + .introspect(.view, on: .macOS(.v12, .v13, .v14, .v15, .v26)) { view in + view.layer?.backgroundColor = NSColor.red.cgColor + } + #endif + } } @MainActor struct GenericViewRepresentable: PlatformViewControllerRepresentable { - #if canImport(UIKit) - typealias UIViewControllerType = PlatformViewController - #elseif canImport(AppKit) - typealias NSViewControllerType = PlatformViewController - #endif + #if canImport(UIKit) + typealias UIViewControllerType = PlatformViewController + #elseif canImport(AppKit) + typealias NSViewControllerType = PlatformViewController + #endif - func makePlatformViewController(context: Context) -> PlatformViewController { - let controller = PlatformViewController(nibName: nil, bundle: nil) - controller.view.translatesAutoresizingMaskIntoConstraints = false + func makePlatformViewController(context: Context) -> PlatformViewController { + let controller = PlatformViewController(nibName: nil, bundle: nil) + controller.view.translatesAutoresizingMaskIntoConstraints = false - let widthConstraint = controller.view.widthAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude) - widthConstraint.priority = .defaultLow + let widthConstraint = controller.view.widthAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude) + widthConstraint.priority = .defaultLow - let heightConstraint = controller.view.heightAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude) - heightConstraint.priority = .defaultLow + let heightConstraint = controller.view.heightAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude) + heightConstraint.priority = .defaultLow - NSLayoutConstraint.activate([widthConstraint, heightConstraint]) + NSLayoutConstraint.activate([widthConstraint, heightConstraint]) - return controller - } + return controller + } - func updatePlatformViewController(_ controller: PlatformViewController, context: Context) { - // NO-OP - } + func updatePlatformViewController(_ controller: PlatformViewController, context: Context) { + // NO-OP + } - static func dismantlePlatformViewController(_ controller: PlatformViewController, coordinator: Coordinator) { - // NO-OP - } + static func dismantlePlatformViewController(_ controller: PlatformViewController, coordinator: Coordinator) { + // NO-OP + } } diff --git a/Package.swift b/Package.swift index a31ff59d..3bca589a 100644 --- a/Package.swift +++ b/Package.swift @@ -3,29 +3,29 @@ import PackageDescription let package = Package( - name: "swiftui-introspect", - platforms: [ - .iOS(.v13), - .tvOS(.v13), - .macOS(.v10_15), - ], - products: [ - .library(name: "SwiftUIIntrospect", targets: ["SwiftUIIntrospect"]), - .library(name: "SwiftUIIntrospect-Static", type: .static, targets: ["SwiftUIIntrospect"]), - .library(name: "SwiftUIIntrospect-Dynamic", type: .dynamic, targets: ["SwiftUIIntrospect"]), - ], - targets: [ - .target( - name: "SwiftUIIntrospect", - path: "Sources" - ), - ] + name: "swiftui-introspect", + platforms: [ + .iOS(.v13), + .tvOS(.v13), + .macOS(.v10_15), + ], + products: [ + .library(name: "SwiftUIIntrospect", targets: ["SwiftUIIntrospect"]), + .library(name: "SwiftUIIntrospect-Static", type: .static, targets: ["SwiftUIIntrospect"]), + .library(name: "SwiftUIIntrospect-Dynamic", type: .dynamic, targets: ["SwiftUIIntrospect"]), + ], + targets: [ + .target( + name: "SwiftUIIntrospect", + path: "Sources" + ), + ] ) for target in package.targets { - target.swiftSettings = target.swiftSettings ?? [] - target.swiftSettings? += [ - .enableUpcomingFeature("ExistentialAny"), - .enableUpcomingFeature("InternalImportsByDefault"), - ] + target.swiftSettings = target.swiftSettings ?? [] + target.swiftSettings? += [ + .enableUpcomingFeature("ExistentialAny"), + .enableUpcomingFeature("InternalImportsByDefault"), + ] } diff --git a/README.md b/README.md index 30be75c3..fb5a7971 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,10 @@ For instance, when introspecting a `ScrollView`... ```swift ScrollView { - Text("Item 1") + Text("Item 1") } .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { scrollView in - // do something with UIScrollView + // do something with UIScrollView } ``` @@ -37,10 +37,10 @@ By default, the `.introspect` modifier acts directly on its _receiver_. This mea ```swift ScrollView { - Text("Item 1") - .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor) { scrollView in - // do something with UIScrollView - } + Text("Item 1") + .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor) { scrollView in + // do something with UIScrollView + } } ``` @@ -61,14 +61,14 @@ Install ```swift let package = Package( - dependencies: [ - .package(url: "https://github.com/siteline/swiftui-introspect", from: "1.0.0"), - ], - targets: [ - .target(name: <#Target Name#>, dependencies: [ - .product(name: "SwiftUIIntrospect", package: "swiftui-introspect"), - ]), - ] + dependencies: [ + .package(url: "https://github.com/siteline/swiftui-introspect", from: "1.0.0"), + ], + targets: [ + .target(name: <#Target Name#>, dependencies: [ + .product(name: "SwiftUIIntrospect", package: "swiftui-introspect"), + ]), + ] ) ``` @@ -151,15 +151,15 @@ Examples ```swift List { - Text("Item") + Text("Item") } .introspect(.list, on: .iOS(.v13, .v14, .v15)) { tableView in - tableView.backgroundView = UIView() - tableView.backgroundColor = .cyan + tableView.backgroundView = UIView() + tableView.backgroundColor = .cyan } .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26)) { collectionView in - collectionView.backgroundView = UIView() - collectionView.subviews.dropFirst(1).first?.backgroundColor = .cyan + collectionView.backgroundView = UIView() + collectionView.subviews.dropFirst(1).first?.backgroundColor = .cyan } ``` @@ -167,10 +167,10 @@ List { ```swift ScrollView { - Text("Item") + Text("Item") } .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { scrollView in - scrollView.backgroundColor = .red + scrollView.backgroundColor = .red } ``` @@ -178,11 +178,11 @@ ScrollView { ```swift NavigationView { - Text("Item") + Text("Item") } .navigationViewStyle(.stack) .introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { navigationController in - navigationController.navigationBar.backgroundColor = .cyan + navigationController.navigationBar.backgroundColor = .cyan } ``` @@ -190,9 +190,9 @@ NavigationView { ```swift TextField("Text Field", text: <#Binding#>) - .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { textField in - textField.backgroundColor = .red - } + .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { textField in + textField.backgroundColor = .red + } ``` Advanced usage @@ -213,44 +213,44 @@ import SwiftUI public struct TextFieldType: IntrospectableViewType {} extension IntrospectableViewType where Self == TextFieldType { - public static var textField: Self { .init() } + public static var textField: Self { .init() } } #if canImport(UIKit) extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif ``` @@ -266,14 +266,14 @@ import SwiftUI @_spi(Advanced) import SwiftUIIntrospect struct ContentView: View { - var body: some View { - ScrollView { - // ... - } - .introspect(.scrollView, on: .iOS(.v13...)) { scrollView in - // ... - } - } + var body: some View { + ScrollView { + // ... + } + .introspect(.scrollView, on: .iOS(.v13...)) { scrollView in + // ... + } + } } ``` @@ -288,16 +288,16 @@ import SwiftUI @_spi(Advanced) import SwiftUIIntrospect struct ContentView: View { - @Weak var scrollView: UIScrollView? - - var body: some View { - ScrollView { - // ... - } - .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { scrollView in - self.scrollView = scrollView - } - } + @Weak var scrollView: UIScrollView? + + var body: some View { + ScrollView { + // ... + } + .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { scrollView in + self.scrollView = scrollView + } + } } ``` diff --git a/Sources/Introspect.swift b/Sources/Introspect.swift index d7b99469..0eadba26 100644 --- a/Sources/Introspect.swift +++ b/Sources/Introspect.swift @@ -5,225 +5,225 @@ public import SwiftUI /// the desired target view relative to the applied `.introspect(...)` /// modifier. public struct IntrospectionScope: OptionSet, Sendable { - /// Look within the `receiver` of the `.introspect(...)` modifier. - public static let receiver = Self(rawValue: 1 << 0) - /// Look for an `ancestor` relative to the `.introspect(...)` modifier. - public static let ancestor = Self(rawValue: 1 << 1) + /// Look within the `receiver` of the `.introspect(...)` modifier. + public static let receiver = Self(rawValue: 1 << 0) + /// Look for an `ancestor` relative to the `.introspect(...)` modifier. + public static let ancestor = Self(rawValue: 1 << 1) - @_spi(Internals) public let rawValue: UInt + @_spi(Internals) public let rawValue: UInt - @_spi(Internals) public init(rawValue: UInt) { - self.rawValue = rawValue - } + @_spi(Internals) public init(rawValue: UInt) { + self.rawValue = rawValue + } } extension View { - /// Introspects a SwiftUI view to find its underlying UIKit/AppKit instance. - /// - /// - Parameters: - /// - viewType: The type of view to be introspected. - /// - platforms: A list of version predicates that specify platform-specific entities associated with the view. - /// - scope: Optionally overrides the view's default scope of introspection. - /// - customize: A closure that hands over the underlying UIKit/AppKit instance ready for customization. - /// - /// Note there is no guarantee of one-time execution for this closure. As `customize` may fire multiple times, - /// make sure to guard against repeated or heavy work in your closure by keeping track of its completeness. - /// - /// Additionally, note mutating SwiftUI state within `customize` will trigger runtime warnings unless that mutation - /// is wrapped in a `DispatchQueue.main.async { ... }` call. This is because introspect attempts to hand you - /// the requested view as soon as possible, and this might mean SwiftUI isn't ready for state mutations at that - /// particular moment. - /// - /// Here's an example usage: - /// - /// ```swift - /// struct ContentView: View { - /// @State var text = "" - /// - /// var body: some View { - /// TextField("Placeholder", text: $text) - /// .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { - /// print(type(of: $0)) // UITextField - /// } - /// } - /// } - /// ``` - @MainActor - public func introspect( - _ viewType: SwiftUIViewType, - on platforms: (PlatformViewVersionPredicate)..., - scope: IntrospectionScope? = nil, - customize: @escaping (PlatformSpecificEntity) -> Void - ) -> some View { - self.modifier(IntrospectModifier(viewType, platforms: platforms, scope: scope, customize: customize)) - } + /// Introspects a SwiftUI view to find its underlying UIKit/AppKit instance. + /// + /// - Parameters: + /// - viewType: The type of view to be introspected. + /// - platforms: A list of version predicates that specify platform-specific entities associated with the view. + /// - scope: Optionally overrides the view's default scope of introspection. + /// - customize: A closure that hands over the underlying UIKit/AppKit instance ready for customization. + /// + /// Note there is no guarantee of one-time execution for this closure. As `customize` may fire multiple times, + /// make sure to guard against repeated or heavy work in your closure by keeping track of its completeness. + /// + /// Additionally, note mutating SwiftUI state within `customize` will trigger runtime warnings unless that mutation + /// is wrapped in a `DispatchQueue.main.async { ... }` call. This is because introspect attempts to hand you + /// the requested view as soon as possible, and this might mean SwiftUI isn't ready for state mutations at that + /// particular moment. + /// + /// Here's an example usage: + /// + /// ```swift + /// struct ContentView: View { + /// @State var text = "" + /// + /// var body: some View { + /// TextField("Placeholder", text: $text) + /// .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { + /// print(type(of: $0)) // UITextField + /// } + /// } + /// } + /// ``` + @MainActor + public func introspect( + _ viewType: SwiftUIViewType, + on platforms: (PlatformViewVersionPredicate)..., + scope: IntrospectionScope? = nil, + customize: @escaping (PlatformSpecificEntity) -> Void + ) -> some View { + self.modifier(IntrospectModifier(viewType, platforms: platforms, scope: scope, customize: customize)) + } } struct IntrospectModifier: ViewModifier { - let id = IntrospectionViewID() - let scope: IntrospectionScope - let selector: IntrospectionSelector? - let customize: (PlatformSpecificEntity) -> Void - - @MainActor - init( - _ viewType: SwiftUIViewType, - platforms: [PlatformViewVersionPredicate], - scope: IntrospectionScope?, - customize: @escaping (PlatformSpecificEntity) -> Void - ) { - self.scope = scope ?? viewType.scope - self.selector = platforms.lazy.compactMap(\.selector).first - self.customize = customize - } - - func body(content: Content) -> some View { - if let selector { - content - .background( - Group { - // box up content for more accurate `.view` introspection - if SwiftUIViewType.self == ViewType.self { - Color.white - .opacity(0) - .accessibility(hidden: true) - } - } - ) - .background( - IntrospectionAnchorView(id: id) - .frame(width: 0, height: 0) - .accessibility(hidden: true) - ) - .overlay( - IntrospectionView(id: id, selector: { selector($0, scope) }, customize: customize) - .frame(width: 0, height: 0) - .accessibility(hidden: true) - ) - } else { - content - } - } + let id = IntrospectionViewID() + let scope: IntrospectionScope + let selector: IntrospectionSelector? + let customize: (PlatformSpecificEntity) -> Void + + @MainActor + init( + _ viewType: SwiftUIViewType, + platforms: [PlatformViewVersionPredicate], + scope: IntrospectionScope?, + customize: @escaping (PlatformSpecificEntity) -> Void + ) { + self.scope = scope ?? viewType.scope + self.selector = platforms.lazy.compactMap(\.selector).first + self.customize = customize + } + + func body(content: Content) -> some View { + if let selector { + content + .background( + Group { + // box up content for more accurate `.view` introspection + if SwiftUIViewType.self == ViewType.self { + Color.white + .opacity(0) + .accessibility(hidden: true) + } + } + ) + .background( + IntrospectionAnchorView(id: id) + .frame(width: 0, height: 0) + .accessibility(hidden: true) + ) + .overlay( + IntrospectionView(id: id, selector: { selector($0, scope) }, customize: customize) + .frame(width: 0, height: 0) + .accessibility(hidden: true) + ) + } else { + content + } + } } @MainActor public protocol PlatformEntity: AnyObject { - associatedtype Base: PlatformEntity + associatedtype Base: PlatformEntity - @_spi(Internals) - var ancestor: Base? { get } + @_spi(Internals) + var ancestor: Base? { get } - @_spi(Internals) - var descendants: [Base] { get } + @_spi(Internals) + var descendants: [Base] { get } - @_spi(Internals) - func isDescendant(of other: Base) -> Bool + @_spi(Internals) + func isDescendant(of other: Base) -> Bool } extension PlatformEntity { - @_spi(Internals) - public var ancestor: Base? { nil } + @_spi(Internals) + public var ancestor: Base? { nil } - @_spi(Internals) - public var descendants: [Base] { [] } + @_spi(Internals) + public var descendants: [Base] { [] } - @_spi(Internals) - public func isDescendant(of other: Base) -> Bool { false } + @_spi(Internals) + public func isDescendant(of other: Base) -> Bool { false } } extension PlatformEntity { - @_spi(Internals) - public var ancestors: some Sequence { - sequence(first: self~, next: { $0.ancestor~ }).dropFirst() - } - - @_spi(Internals) - public var allDescendants: some Sequence { - recursiveSequence([self~], children: { $0.descendants~ }).dropFirst() - } - - func nearestCommonAncestor(with other: Base) -> Base? { - var nearestAncestor: Base? = self~ - - while let currentEntity = nearestAncestor, !other.isDescendant(of: currentEntity~) { - nearestAncestor = currentEntity.ancestor~ - } - - return nearestAncestor - } - - func allDescendants(between bottomEntity: Base, and topEntity: Base) -> some Sequence { - self.allDescendants - .lazy - .drop(while: { $0 !== bottomEntity }) - .prefix(while: { $0 !== topEntity }) - } - - func receiver( - ofType type: PlatformSpecificEntity.Type - ) -> PlatformSpecificEntity? { - let frontEntity = self - guard - let backEntity = frontEntity.introspectionAnchorEntity, - let commonAncestor = backEntity.nearestCommonAncestor(with: frontEntity~) - else { - return nil - } - - return commonAncestor - .allDescendants(between: backEntity~, and: frontEntity~) - .filter { !$0.isIntrospectionPlatformEntity } - .compactMap { $0 as? PlatformSpecificEntity } - .first - } - - func ancestor( - ofType type: PlatformSpecificEntity.Type - ) -> PlatformSpecificEntity? { - self.ancestors - .lazy - .filter { !$0.isIntrospectionPlatformEntity } - .compactMap { $0 as? PlatformSpecificEntity } - .first - } + @_spi(Internals) + public var ancestors: some Sequence { + sequence(first: self~, next: { $0.ancestor~ }).dropFirst() + } + + @_spi(Internals) + public var allDescendants: some Sequence { + recursiveSequence([self~], children: { $0.descendants~ }).dropFirst() + } + + func nearestCommonAncestor(with other: Base) -> Base? { + var nearestAncestor: Base? = self~ + + while let currentEntity = nearestAncestor, !other.isDescendant(of: currentEntity~) { + nearestAncestor = currentEntity.ancestor~ + } + + return nearestAncestor + } + + func allDescendants(between bottomEntity: Base, and topEntity: Base) -> some Sequence { + self.allDescendants + .lazy + .drop(while: { $0 !== bottomEntity }) + .prefix(while: { $0 !== topEntity }) + } + + func receiver( + ofType type: PlatformSpecificEntity.Type + ) -> PlatformSpecificEntity? { + let frontEntity = self + guard + let backEntity = frontEntity.introspectionAnchorEntity, + let commonAncestor = backEntity.nearestCommonAncestor(with: frontEntity~) + else { + return nil + } + + return commonAncestor + .allDescendants(between: backEntity~, and: frontEntity~) + .filter { !$0.isIntrospectionPlatformEntity } + .compactMap { $0 as? PlatformSpecificEntity } + .first + } + + func ancestor( + ofType type: PlatformSpecificEntity.Type + ) -> PlatformSpecificEntity? { + self.ancestors + .lazy + .filter { !$0.isIntrospectionPlatformEntity } + .compactMap { $0 as? PlatformSpecificEntity } + .first + } } extension PlatformView: PlatformEntity { - @_spi(Internals) - public var ancestor: PlatformView? { - superview - } - - @_spi(Internals) - public var descendants: [PlatformView] { - subviews - } + @_spi(Internals) + public var ancestor: PlatformView? { + superview + } + + @_spi(Internals) + public var descendants: [PlatformView] { + subviews + } } extension PlatformViewController: PlatformEntity { - @_spi(Internals) - public var ancestor: PlatformViewController? { - parent - } - - @_spi(Internals) - public var descendants: [PlatformViewController] { - children - } - - @_spi(Internals) - public func isDescendant(of other: PlatformViewController) -> Bool { - self.ancestors.contains(other) - } + @_spi(Internals) + public var ancestor: PlatformViewController? { + parent + } + + @_spi(Internals) + public var descendants: [PlatformViewController] { + children + } + + @_spi(Internals) + public func isDescendant(of other: PlatformViewController) -> Bool { + self.ancestors.contains(other) + } } #if canImport(UIKit) extension UIPresentationController: PlatformEntity { - public typealias Base = UIPresentationController + public typealias Base = UIPresentationController } #elseif canImport(AppKit) extension NSWindow: PlatformEntity { - public typealias Base = NSWindow + public typealias Base = NSWindow } #endif #endif diff --git a/Sources/IntrospectableViewType.swift b/Sources/IntrospectableViewType.swift index 8851e6ce..f0976e4b 100644 --- a/Sources/IntrospectableViewType.swift +++ b/Sources/IntrospectableViewType.swift @@ -1,20 +1,20 @@ #if !os(watchOS) @MainActor public protocol IntrospectableViewType { - /// The scope of introspection for this particular view type, i.e. where introspect - /// should look to find the desired target view relative to the applied - /// `.introspect(...)` modifier. - /// - /// While the scope can be overridden by the user in their `.introspect(...)` call, - /// most of the time it's preferable to defer to the view type's own scope, - /// as it guarantees introspection is working as intended by the vendor. - /// - /// Defaults to `.receiver` if left unimplemented, which is a sensible one in - /// most cases if you're looking to implement your own view type. - var scope: IntrospectionScope { get } + /// The scope of introspection for this particular view type, i.e. where introspect + /// should look to find the desired target view relative to the applied + /// `.introspect(...)` modifier. + /// + /// While the scope can be overridden by the user in their `.introspect(...)` call, + /// most of the time it's preferable to defer to the view type's own scope, + /// as it guarantees introspection is working as intended by the vendor. + /// + /// Defaults to `.receiver` if left unimplemented, which is a sensible one in + /// most cases if you're looking to implement your own view type. + var scope: IntrospectionScope { get } } extension IntrospectableViewType { - public var scope: IntrospectionScope { .receiver } + public var scope: IntrospectionScope { .receiver } } #endif diff --git a/Sources/IntrospectionSelector.swift b/Sources/IntrospectionSelector.swift index 382c10c8..76fcbe7d 100644 --- a/Sources/IntrospectionSelector.swift +++ b/Sources/IntrospectionSelector.swift @@ -8,75 +8,75 @@ public import AppKit @_spi(Advanced) @MainActor public struct IntrospectionSelector { - @_spi(Advanced) - public static var `default`: Self { .from(Target.self, selector: { $0 }) } + @_spi(Advanced) + public static var `default`: Self { .from(Target.self, selector: { $0 }) } - @_spi(Advanced) - public static func from(_ entryType: Entry.Type, selector: @MainActor @escaping (Entry) -> Target?) -> Self { - .init( - receiverSelector: { controller in - controller.as(Entry.Base.self)?.receiver(ofType: Entry.self).flatMap(selector) - }, - ancestorSelector: { controller in - controller.as(Entry.Base.self)?.ancestor(ofType: Entry.self).flatMap(selector) - } - ) - } + @_spi(Advanced) + public static func from(_ entryType: Entry.Type, selector: @MainActor @escaping (Entry) -> Target?) -> Self { + .init( + receiverSelector: { controller in + controller.as(Entry.Base.self)?.receiver(ofType: Entry.self).flatMap(selector) + }, + ancestorSelector: { controller in + controller.as(Entry.Base.self)?.ancestor(ofType: Entry.self).flatMap(selector) + } + ) + } - private var receiverSelector: @MainActor (IntrospectionPlatformViewController) -> Target? - private var ancestorSelector: @MainActor (IntrospectionPlatformViewController) -> Target? + private var receiverSelector: @MainActor (IntrospectionPlatformViewController) -> Target? + private var ancestorSelector: @MainActor (IntrospectionPlatformViewController) -> Target? - private init( - receiverSelector: @MainActor @escaping (IntrospectionPlatformViewController) -> Target?, - ancestorSelector: @MainActor @escaping (IntrospectionPlatformViewController) -> Target? - ) { - self.receiverSelector = receiverSelector - self.ancestorSelector = ancestorSelector - } + private init( + receiverSelector: @MainActor @escaping (IntrospectionPlatformViewController) -> Target?, + ancestorSelector: @MainActor @escaping (IntrospectionPlatformViewController) -> Target? + ) { + self.receiverSelector = receiverSelector + self.ancestorSelector = ancestorSelector + } - @_spi(Advanced) - public func withReceiverSelector(_ selector: @MainActor @escaping (PlatformViewController) -> Target?) -> Self { - var copy = self - copy.receiverSelector = selector - return copy - } + @_spi(Advanced) + public func withReceiverSelector(_ selector: @MainActor @escaping (PlatformViewController) -> Target?) -> Self { + var copy = self + copy.receiverSelector = selector + return copy + } - @_spi(Advanced) - public func withAncestorSelector(_ selector: @MainActor @escaping (PlatformViewController) -> Target?) -> Self { - var copy = self - copy.ancestorSelector = selector - return copy - } + @_spi(Advanced) + public func withAncestorSelector(_ selector: @MainActor @escaping (PlatformViewController) -> Target?) -> Self { + var copy = self + copy.ancestorSelector = selector + return copy + } - func callAsFunction(_ controller: IntrospectionPlatformViewController, _ scope: IntrospectionScope) -> Target? { - if - scope.contains(.receiver), - let target = receiverSelector(controller) - { - return target - } - if - scope.contains(.ancestor), - let target = ancestorSelector(controller) - { - return target - } - return nil - } + func callAsFunction(_ controller: IntrospectionPlatformViewController, _ scope: IntrospectionScope) -> Target? { + if + scope.contains(.receiver), + let target = receiverSelector(controller) + { + return target + } + if + scope.contains(.ancestor), + let target = ancestorSelector(controller) + { + return target + } + return nil + } } extension PlatformViewController { - func `as`(_ baseType: Base.Type) -> (any PlatformEntity)? { - if Base.self == PlatformView.self { - #if canImport(UIKit) - return viewIfLoaded - #elseif canImport(AppKit) - return isViewLoaded ? view : nil - #endif - } else if Base.self == PlatformViewController.self { - return self - } - return nil - } + func `as`(_ baseType: Base.Type) -> (any PlatformEntity)? { + if Base.self == PlatformView.self { + #if canImport(UIKit) + return viewIfLoaded + #elseif canImport(AppKit) + return isViewLoaded ? view : nil + #endif + } else if Base.self == PlatformViewController.self { + return self + } + return nil + } } #endif diff --git a/Sources/IntrospectionView.swift b/Sources/IntrospectionView.swift index bbdfa73a..4885e8a8 100644 --- a/Sources/IntrospectionView.swift +++ b/Sources/IntrospectionView.swift @@ -5,232 +5,232 @@ typealias IntrospectionViewID = UUID @MainActor fileprivate enum IntrospectionStore { - static var shared: [IntrospectionViewID: Pair] = [:] + static var shared: [IntrospectionViewID: Pair] = [:] - struct Pair { - weak var controller: IntrospectionPlatformViewController? - weak var anchor: IntrospectionAnchorPlatformViewController? - } + struct Pair { + weak var controller: IntrospectionPlatformViewController? + weak var anchor: IntrospectionAnchorPlatformViewController? + } } extension PlatformEntity { - var introspectionAnchorEntity: Base? { - if let introspectionController = self as? IntrospectionPlatformViewController { - return IntrospectionStore.shared[introspectionController.id]?.anchor~ - } - if - let view = self as? PlatformView, - let introspectionController = view.introspectionController - { - return IntrospectionStore.shared[introspectionController.id]?.anchor?.view~ - } - return nil - } + var introspectionAnchorEntity: Base? { + if let introspectionController = self as? IntrospectionPlatformViewController { + return IntrospectionStore.shared[introspectionController.id]?.anchor~ + } + if + let view = self as? PlatformView, + let introspectionController = view.introspectionController + { + return IntrospectionStore.shared[introspectionController.id]?.anchor?.view~ + } + return nil + } } /// ⚓️ struct IntrospectionAnchorView: PlatformViewControllerRepresentable { - #if canImport(UIKit) - typealias UIViewControllerType = IntrospectionAnchorPlatformViewController - #elseif canImport(AppKit) - typealias NSViewControllerType = IntrospectionAnchorPlatformViewController - #endif + #if canImport(UIKit) + typealias UIViewControllerType = IntrospectionAnchorPlatformViewController + #elseif canImport(AppKit) + typealias NSViewControllerType = IntrospectionAnchorPlatformViewController + #endif - @Binding - private var observed: Void // workaround for state changes not triggering view updates + @Binding + private var observed: Void // workaround for state changes not triggering view updates - let id: IntrospectionViewID + let id: IntrospectionViewID - init(id: IntrospectionViewID) { - self._observed = .constant(()) - self.id = id - } + init(id: IntrospectionViewID) { + self._observed = .constant(()) + self.id = id + } - func makePlatformViewController(context: Context) -> IntrospectionAnchorPlatformViewController { - IntrospectionAnchorPlatformViewController(id: id) - } + func makePlatformViewController(context: Context) -> IntrospectionAnchorPlatformViewController { + IntrospectionAnchorPlatformViewController(id: id) + } - func updatePlatformViewController(_ controller: IntrospectionAnchorPlatformViewController, context: Context) {} + func updatePlatformViewController(_ controller: IntrospectionAnchorPlatformViewController, context: Context) {} - static func dismantlePlatformViewController(_ controller: IntrospectionAnchorPlatformViewController, coordinator: Coordinator) {} + static func dismantlePlatformViewController(_ controller: IntrospectionAnchorPlatformViewController, coordinator: Coordinator) {} } final class IntrospectionAnchorPlatformViewController: PlatformViewController { - init(id: IntrospectionViewID) { - super.init(nibName: nil, bundle: nil) - self.isIntrospectionPlatformEntity = true - IntrospectionStore.shared[id, default: .init()].anchor = self - } - - @available(*, unavailable) - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - #if canImport(UIKit) - override func viewDidLoad() { - super.viewDidLoad() - view.isIntrospectionPlatformEntity = true - } - #elseif canImport(AppKit) - override func loadView() { - view = NSView() - view.isIntrospectionPlatformEntity = true - } - #endif + init(id: IntrospectionViewID) { + super.init(nibName: nil, bundle: nil) + self.isIntrospectionPlatformEntity = true + IntrospectionStore.shared[id, default: .init()].anchor = self + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + #if canImport(UIKit) + override func viewDidLoad() { + super.viewDidLoad() + view.isIntrospectionPlatformEntity = true + } + #elseif canImport(AppKit) + override func loadView() { + view = NSView() + view.isIntrospectionPlatformEntity = true + } + #endif } struct IntrospectionView: PlatformViewControllerRepresentable { - #if canImport(UIKit) - typealias UIViewControllerType = IntrospectionPlatformViewController - #elseif canImport(AppKit) - typealias NSViewControllerType = IntrospectionPlatformViewController - #endif - - final class TargetCache { - weak var target: Target? - } - - @Binding - private var observed: Void // workaround for state changes not triggering view updates - private let id: IntrospectionViewID - private let selector: (IntrospectionPlatformViewController) -> Target? - private let customize: (Target) -> Void - - init( - id: IntrospectionViewID, - selector: @escaping (IntrospectionPlatformViewController) -> Target?, - customize: @escaping (Target) -> Void - ) { - self._observed = .constant(()) - self.id = id - self.selector = selector - self.customize = customize - } - - func makeCoordinator() -> TargetCache { - TargetCache() - } - - func makePlatformViewController(context: Context) -> IntrospectionPlatformViewController { - let controller = IntrospectionPlatformViewController(id: id) { controller in - guard let target = selector(controller) else { - return - } - context.coordinator.target = target - customize(target) - controller.handler = nil - } - return controller - } - - func updatePlatformViewController(_ controller: IntrospectionPlatformViewController, context: Context) { - guard let target = context.coordinator.target ?? selector(controller) else { - return - } - customize(target) - } - - static func dismantlePlatformViewController(_ controller: IntrospectionPlatformViewController, coordinator: Coordinator) { - controller.handler = nil - } + #if canImport(UIKit) + typealias UIViewControllerType = IntrospectionPlatformViewController + #elseif canImport(AppKit) + typealias NSViewControllerType = IntrospectionPlatformViewController + #endif + + final class TargetCache { + weak var target: Target? + } + + @Binding + private var observed: Void // workaround for state changes not triggering view updates + private let id: IntrospectionViewID + private let selector: (IntrospectionPlatformViewController) -> Target? + private let customize: (Target) -> Void + + init( + id: IntrospectionViewID, + selector: @escaping (IntrospectionPlatformViewController) -> Target?, + customize: @escaping (Target) -> Void + ) { + self._observed = .constant(()) + self.id = id + self.selector = selector + self.customize = customize + } + + func makeCoordinator() -> TargetCache { + TargetCache() + } + + func makePlatformViewController(context: Context) -> IntrospectionPlatformViewController { + let controller = IntrospectionPlatformViewController(id: id) { controller in + guard let target = selector(controller) else { + return + } + context.coordinator.target = target + customize(target) + controller.handler = nil + } + return controller + } + + func updatePlatformViewController(_ controller: IntrospectionPlatformViewController, context: Context) { + guard let target = context.coordinator.target ?? selector(controller) else { + return + } + customize(target) + } + + static func dismantlePlatformViewController(_ controller: IntrospectionPlatformViewController, coordinator: Coordinator) { + controller.handler = nil + } } final class IntrospectionPlatformViewController: PlatformViewController { - let id: IntrospectionViewID - var handler: (() -> Void)? = nil - - fileprivate init( - id: IntrospectionViewID, - handler: ((IntrospectionPlatformViewController) -> Void)? - ) { - self.id = id - super.init(nibName: nil, bundle: nil) - self.handler = { [weak self] in - guard let self else { return } - handler?(self) - } - self.isIntrospectionPlatformEntity = true - IntrospectionStore.shared[id, default: .init()].controller = self - } - - @available(*, unavailable) - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - #if canImport(UIKit) - #if os(iOS) - override var preferredStatusBarStyle: UIStatusBarStyle { - parent?.preferredStatusBarStyle ?? super.preferredStatusBarStyle - } - #endif - - override func viewDidLoad() { - super.viewDidLoad() - view.introspectionController = self - view.isIntrospectionPlatformEntity = true - handler?() - } - - override func didMove(toParent parent: UIViewController?) { - super.didMove(toParent: parent) - handler?() - } - - override func viewDidLayoutSubviews() { - super.viewDidLayoutSubviews() - handler?() - } - - override func viewDidAppear(_ animated: Bool) { - super.viewDidAppear(animated) - handler?() - } - #elseif canImport(AppKit) - override func loadView() { - view = NSView() - view.introspectionController = self - view.isIntrospectionPlatformEntity = true - } - - override func viewDidLoad() { - super.viewDidLoad() - handler?() - } - - override func viewDidAppear() { - super.viewDidAppear() - handler?() - } - #endif + let id: IntrospectionViewID + var handler: (() -> Void)? = nil + + fileprivate init( + id: IntrospectionViewID, + handler: ((IntrospectionPlatformViewController) -> Void)? + ) { + self.id = id + super.init(nibName: nil, bundle: nil) + self.handler = { [weak self] in + guard let self else { return } + handler?(self) + } + self.isIntrospectionPlatformEntity = true + IntrospectionStore.shared[id, default: .init()].controller = self + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + #if canImport(UIKit) + #if os(iOS) + override var preferredStatusBarStyle: UIStatusBarStyle { + parent?.preferredStatusBarStyle ?? super.preferredStatusBarStyle + } + #endif + + override func viewDidLoad() { + super.viewDidLoad() + view.introspectionController = self + view.isIntrospectionPlatformEntity = true + handler?() + } + + override func didMove(toParent parent: UIViewController?) { + super.didMove(toParent: parent) + handler?() + } + + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + handler?() + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + handler?() + } + #elseif canImport(AppKit) + override func loadView() { + view = NSView() + view.introspectionController = self + view.isIntrospectionPlatformEntity = true + } + + override func viewDidLoad() { + super.viewDidLoad() + handler?() + } + + override func viewDidAppear() { + super.viewDidAppear() + handler?() + } + #endif } import ObjectiveC extension PlatformView { - fileprivate var introspectionController: IntrospectionPlatformViewController? { - get { - let key = unsafeBitCast(Selector(#function), to: UnsafeRawPointer.self) - return objc_getAssociatedObject(self, key) as? IntrospectionPlatformViewController - } - set { - let key = unsafeBitCast(Selector(#function), to: UnsafeRawPointer.self) - objc_setAssociatedObject(self, key, newValue, .OBJC_ASSOCIATION_ASSIGN) - } - } + fileprivate var introspectionController: IntrospectionPlatformViewController? { + get { + let key = unsafeBitCast(Selector(#function), to: UnsafeRawPointer.self) + return objc_getAssociatedObject(self, key) as? IntrospectionPlatformViewController + } + set { + let key = unsafeBitCast(Selector(#function), to: UnsafeRawPointer.self) + objc_setAssociatedObject(self, key, newValue, .OBJC_ASSOCIATION_ASSIGN) + } + } } extension PlatformEntity { - var isIntrospectionPlatformEntity: Bool { - get { - let key = unsafeBitCast(Selector(#function), to: UnsafeRawPointer.self) - return objc_getAssociatedObject(self, key) as? Bool ?? false - } - set { - let key = unsafeBitCast(Selector(#function), to: UnsafeRawPointer.self) - objc_setAssociatedObject(self, key, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) - } - } + var isIntrospectionPlatformEntity: Bool { + get { + let key = unsafeBitCast(Selector(#function), to: UnsafeRawPointer.self) + return objc_getAssociatedObject(self, key) as? Bool ?? false + } + set { + let key = unsafeBitCast(Selector(#function), to: UnsafeRawPointer.self) + objc_setAssociatedObject(self, key, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } } #endif diff --git a/Sources/PlatformVersion.swift b/Sources/PlatformVersion.swift index 7c860b63..771eee7f 100644 --- a/Sources/PlatformVersion.swift +++ b/Sources/PlatformVersion.swift @@ -3,434 +3,434 @@ import Foundation @_spi(Internals) public enum PlatformVersionCondition: Sendable { - case past - case current - case future + case past + case current + case future } public protocol PlatformVersion: Sendable { - @_spi(Internals) - var condition: PlatformVersionCondition? { get } + @_spi(Internals) + var condition: PlatformVersionCondition? { get } } extension PlatformVersion { - @_spi(Internals) - public var isCurrent: Bool { - condition == .current - } - - @_spi(Internals) - public var isCurrentOrPast: Bool { - condition == .current || condition == .past - } + @_spi(Internals) + public var isCurrent: Bool { + condition == .current + } + + @_spi(Internals) + public var isCurrentOrPast: Bool { + condition == .current || condition == .past + } - @_spi(Internals) - public var condition: PlatformVersionCondition? { nil } + @_spi(Internals) + public var condition: PlatformVersionCondition? { nil } } public struct iOSVersion: PlatformVersion { - @_spi(Internals) - public let condition: PlatformVersionCondition? + @_spi(Internals) + public let condition: PlatformVersionCondition? - @_spi(Internals) - public init(condition: () -> PlatformVersionCondition?) { - self.condition = condition() - } + @_spi(Internals) + public init(condition: () -> PlatformVersionCondition?) { + self.condition = condition() + } } extension iOSVersion { - public static let v13 = iOSVersion { - #if os(iOS) - if #available(iOS 14, *) { - return .past - } - if #available(iOS 13, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v14 = iOSVersion { - #if os(iOS) - if #available(iOS 15, *) { - return .past - } - if #available(iOS 14, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v15 = iOSVersion { - #if os(iOS) - if #available(iOS 16, *) { - return .past - } - if #available(iOS 15, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v16 = iOSVersion { - #if os(iOS) - if #available(iOS 17, *) { - return .past - } - if #available(iOS 16, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v17 = iOSVersion { - #if os(iOS) - if #available(iOS 18, *) { - return .past - } - if #available(iOS 17, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v18 = iOSVersion { - #if os(iOS) - if #available(iOS 19, *) { - return .past - } - if #available(iOS 18, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v26 = iOSVersion { - #if os(iOS) - if #available(iOS 27, *) { - return .past - } - // Apps built before the iOS 26 SDK get "19.0" as the system version from ProcessInfo. - // Once built with the iOS 26 SDK, the version then becomes "26.0". - if #available(iOS 19, *) { - return .current - } - return .future - #else - return nil - #endif - } + public static let v13 = iOSVersion { + #if os(iOS) + if #available(iOS 14, *) { + return .past + } + if #available(iOS 13, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v14 = iOSVersion { + #if os(iOS) + if #available(iOS 15, *) { + return .past + } + if #available(iOS 14, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v15 = iOSVersion { + #if os(iOS) + if #available(iOS 16, *) { + return .past + } + if #available(iOS 15, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v16 = iOSVersion { + #if os(iOS) + if #available(iOS 17, *) { + return .past + } + if #available(iOS 16, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v17 = iOSVersion { + #if os(iOS) + if #available(iOS 18, *) { + return .past + } + if #available(iOS 17, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v18 = iOSVersion { + #if os(iOS) + if #available(iOS 19, *) { + return .past + } + if #available(iOS 18, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v26 = iOSVersion { + #if os(iOS) + if #available(iOS 27, *) { + return .past + } + // Apps built before the iOS 26 SDK get "19.0" as the system version from ProcessInfo. + // Once built with the iOS 26 SDK, the version then becomes "26.0". + if #available(iOS 19, *) { + return .current + } + return .future + #else + return nil + #endif + } } public struct tvOSVersion: PlatformVersion { - @_spi(Internals) - public let condition: PlatformVersionCondition? + @_spi(Internals) + public let condition: PlatformVersionCondition? - @_spi(Internals) - public init(condition: () -> PlatformVersionCondition?) { - self.condition = condition() - } + @_spi(Internals) + public init(condition: () -> PlatformVersionCondition?) { + self.condition = condition() + } } extension tvOSVersion { - public static let v13 = tvOSVersion { - #if os(tvOS) - if #available(tvOS 14, *) { - return .past - } - if #available(tvOS 13, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v14 = tvOSVersion { - #if os(tvOS) - if #available(tvOS 15, *) { - return .past - } - if #available(tvOS 14, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v15 = tvOSVersion { - #if os(tvOS) - if #available(tvOS 16, *) { - return .past - } - if #available(tvOS 15, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v16 = tvOSVersion { - #if os(tvOS) - if #available(tvOS 17, *) { - return .past - } - if #available(tvOS 16, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v17 = tvOSVersion { - #if os(tvOS) - if #available(tvOS 18, *) { - return .past - } - if #available(tvOS 17, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v18 = tvOSVersion { - #if os(tvOS) - if #available(tvOS 19, *) { - return .past - } - if #available(tvOS 18, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v26 = tvOSVersion { - #if os(tvOS) - if #available(tvOS 27, *) { - return .past - } - // Apps built before the tvOS 26 SDK get "19.0" as the system version from ProcessInfo. - // Once built with the tvOS 26 SDK, the version then becomes "26.0". - if #available(tvOS 19, *) { - return .current - } - return .future - #else - return nil - #endif - } + public static let v13 = tvOSVersion { + #if os(tvOS) + if #available(tvOS 14, *) { + return .past + } + if #available(tvOS 13, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v14 = tvOSVersion { + #if os(tvOS) + if #available(tvOS 15, *) { + return .past + } + if #available(tvOS 14, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v15 = tvOSVersion { + #if os(tvOS) + if #available(tvOS 16, *) { + return .past + } + if #available(tvOS 15, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v16 = tvOSVersion { + #if os(tvOS) + if #available(tvOS 17, *) { + return .past + } + if #available(tvOS 16, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v17 = tvOSVersion { + #if os(tvOS) + if #available(tvOS 18, *) { + return .past + } + if #available(tvOS 17, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v18 = tvOSVersion { + #if os(tvOS) + if #available(tvOS 19, *) { + return .past + } + if #available(tvOS 18, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v26 = tvOSVersion { + #if os(tvOS) + if #available(tvOS 27, *) { + return .past + } + // Apps built before the tvOS 26 SDK get "19.0" as the system version from ProcessInfo. + // Once built with the tvOS 26 SDK, the version then becomes "26.0". + if #available(tvOS 19, *) { + return .current + } + return .future + #else + return nil + #endif + } } public struct macOSVersion: PlatformVersion { - @_spi(Internals) - public let condition: PlatformVersionCondition? + @_spi(Internals) + public let condition: PlatformVersionCondition? - @_spi(Internals) - public init(condition: () -> PlatformVersionCondition?) { - self.condition = condition() - } + @_spi(Internals) + public init(condition: () -> PlatformVersionCondition?) { + self.condition = condition() + } } extension macOSVersion { - public static let v10_15 = macOSVersion { - #if os(macOS) - if #available(macOS 11, *) { - return .past - } - if #available(macOS 10.15, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v10_15_4 = macOSVersion { - #if os(macOS) - if #available(macOS 11, *) { - return .past - } - if #available(macOS 10.15.4, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v11 = macOSVersion { - #if os(macOS) - if #available(macOS 12, *) { - return .past - } - if #available(macOS 11, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v12 = macOSVersion { - #if os(macOS) - if #available(macOS 13, *) { - return .past - } - if #available(macOS 12, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v13 = macOSVersion { - #if os(macOS) - if #available(macOS 14, *) { - return .past - } - if #available(macOS 13, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v14 = macOSVersion { - #if os(macOS) - if #available(macOS 15, *) { - return .past - } - if #available(macOS 14, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v15 = macOSVersion { - #if os(macOS) - if #available(macOS 16, *) { - return .past - } - if #available(macOS 15, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v26 = macOSVersion { - #if os(macOS) - if #available(macOS 27, *) { - return .past - } - // Apps built before the macOS 26 SDK get "16.0" as the system version from ProcessInfo. - // Once built with the macOS 26 SDK, the version then becomes "26.0". - if #available(macOS 16, *) { - return .current - } - return .future - #else - return nil - #endif - } + public static let v10_15 = macOSVersion { + #if os(macOS) + if #available(macOS 11, *) { + return .past + } + if #available(macOS 10.15, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v10_15_4 = macOSVersion { + #if os(macOS) + if #available(macOS 11, *) { + return .past + } + if #available(macOS 10.15.4, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v11 = macOSVersion { + #if os(macOS) + if #available(macOS 12, *) { + return .past + } + if #available(macOS 11, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v12 = macOSVersion { + #if os(macOS) + if #available(macOS 13, *) { + return .past + } + if #available(macOS 12, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v13 = macOSVersion { + #if os(macOS) + if #available(macOS 14, *) { + return .past + } + if #available(macOS 13, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v14 = macOSVersion { + #if os(macOS) + if #available(macOS 15, *) { + return .past + } + if #available(macOS 14, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v15 = macOSVersion { + #if os(macOS) + if #available(macOS 16, *) { + return .past + } + if #available(macOS 15, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v26 = macOSVersion { + #if os(macOS) + if #available(macOS 27, *) { + return .past + } + // Apps built before the macOS 26 SDK get "16.0" as the system version from ProcessInfo. + // Once built with the macOS 26 SDK, the version then becomes "26.0". + if #available(macOS 16, *) { + return .current + } + return .future + #else + return nil + #endif + } } public struct visionOSVersion: PlatformVersion { - @_spi(Internals) - public let condition: PlatformVersionCondition? + @_spi(Internals) + public let condition: PlatformVersionCondition? - @_spi(Internals) - public init(condition: () -> PlatformVersionCondition?) { - self.condition = condition() - } + @_spi(Internals) + public init(condition: () -> PlatformVersionCondition?) { + self.condition = condition() + } } extension visionOSVersion { - public static let v1 = visionOSVersion { - #if os(visionOS) - if #available(visionOS 2, *) { - return .past - } - if #available(visionOS 1, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v2 = visionOSVersion { - #if os(visionOS) - if #available(visionOS 3, *) { - return .past - } - if #available(visionOS 2, *) { - return .current - } - return .future - #else - return nil - #endif - } - - public static let v26 = visionOSVersion { - #if os(visionOS) - if #available(visionOS 27, *) { - return .past - } - // Apps built before the visionOS 26 SDK get "3.0" as the system version from ProcessInfo. - // Once built with the visionOS 26 SDK, the version then becomes "26.0". - if #available(visionOS 3, *) { - return .current - } - return .future - #else - return nil - #endif - } + public static let v1 = visionOSVersion { + #if os(visionOS) + if #available(visionOS 2, *) { + return .past + } + if #available(visionOS 1, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v2 = visionOSVersion { + #if os(visionOS) + if #available(visionOS 3, *) { + return .past + } + if #available(visionOS 2, *) { + return .current + } + return .future + #else + return nil + #endif + } + + public static let v26 = visionOSVersion { + #if os(visionOS) + if #available(visionOS 27, *) { + return .past + } + // Apps built before the visionOS 26 SDK get "3.0" as the system version from ProcessInfo. + // Once built with the visionOS 26 SDK, the version then becomes "26.0". + if #available(visionOS 3, *) { + return .current + } + return .future + #else + return nil + #endif + } } #endif diff --git a/Sources/PlatformView.swift b/Sources/PlatformView.swift index 02e578e1..c5c406e8 100644 --- a/Sources/PlatformView.swift +++ b/Sources/PlatformView.swift @@ -24,39 +24,39 @@ public typealias _PlatformViewControllerRepresentable = NSViewControllerRepresen @MainActor @_spi(Internals) public protocol PlatformViewControllerRepresentable: _PlatformViewControllerRepresentable { - #if canImport(UIKit) - typealias ViewController = UIViewControllerType - #elseif canImport(AppKit) - typealias ViewController = NSViewControllerType - #endif + #if canImport(UIKit) + typealias ViewController = UIViewControllerType + #elseif canImport(AppKit) + typealias ViewController = NSViewControllerType + #endif - func makePlatformViewController(context: Context) -> ViewController - func updatePlatformViewController(_ controller: ViewController, context: Context) - static func dismantlePlatformViewController(_ controller: ViewController, coordinator: Coordinator) + func makePlatformViewController(context: Context) -> ViewController + func updatePlatformViewController(_ controller: ViewController, context: Context) + static func dismantlePlatformViewController(_ controller: ViewController, coordinator: Coordinator) } @_spi(Internals) public extension PlatformViewControllerRepresentable { - #if canImport(UIKit) - func makeUIViewController(context: Context) -> ViewController { - makePlatformViewController(context: context) - } - func updateUIViewController(_ controller: ViewController, context: Context) { - updatePlatformViewController(controller, context: context) - } - static func dismantleUIViewController(_ controller: ViewController, coordinator: Coordinator) { - dismantlePlatformViewController(controller, coordinator: coordinator) - } - #elseif canImport(AppKit) - func makeNSViewController(context: Context) -> ViewController { - makePlatformViewController(context: context) - } - func updateNSViewController(_ controller: ViewController, context: Context) { - updatePlatformViewController(controller, context: context) - } - static func dismantleNSViewController(_ controller: ViewController, coordinator: Coordinator) { - dismantlePlatformViewController(controller, coordinator: coordinator) - } - #endif + #if canImport(UIKit) + func makeUIViewController(context: Context) -> ViewController { + makePlatformViewController(context: context) + } + func updateUIViewController(_ controller: ViewController, context: Context) { + updatePlatformViewController(controller, context: context) + } + static func dismantleUIViewController(_ controller: ViewController, coordinator: Coordinator) { + dismantlePlatformViewController(controller, coordinator: coordinator) + } + #elseif canImport(AppKit) + func makeNSViewController(context: Context) -> ViewController { + makePlatformViewController(context: context) + } + func updateNSViewController(_ controller: ViewController, context: Context) { + updatePlatformViewController(controller, context: context) + } + static func dismantleNSViewController(_ controller: ViewController, coordinator: Coordinator) { + dismantlePlatformViewController(controller, coordinator: coordinator) + } + #endif } #endif diff --git a/Sources/PlatformViewVersion.swift b/Sources/PlatformViewVersion.swift index 5c78d5db..bce22767 100644 --- a/Sources/PlatformViewVersion.swift +++ b/Sources/PlatformViewVersion.swift @@ -3,126 +3,126 @@ import SwiftUI @MainActor public struct PlatformViewVersionPredicate { - let selector: IntrospectionSelector? - - private init( - _ versions: [PlatformViewVersion], - matches: (PlatformViewVersion) -> Bool - ) { - if let matchingVersion = versions.first(where: matches) { - self.selector = matchingVersion.selector ?? .default - } else { - self.selector = nil - } - } - - public static func iOS(_ versions: (iOSViewVersion)...) -> Self { - Self(versions, matches: \.isCurrent) - } - - @_spi(Advanced) - public static func iOS(_ versions: PartialRangeFrom>) -> Self { - Self([versions.lowerBound], matches: \.isCurrentOrPast) - } - - public static func tvOS(_ versions: (tvOSViewVersion)...) -> Self { - Self(versions, matches: \.isCurrent) - } - - @_spi(Advanced) - public static func tvOS(_ versions: PartialRangeFrom>) -> Self { - Self([versions.lowerBound], matches: \.isCurrentOrPast) - } - - public static func macOS(_ versions: (macOSViewVersion)...) -> Self { - Self(versions, matches: \.isCurrent) - } - - @_spi(Advanced) - public static func macOS(_ versions: PartialRangeFrom>) -> Self { - Self([versions.lowerBound], matches: \.isCurrentOrPast) - } - - public static func visionOS(_ versions: (visionOSViewVersion)...) -> Self { - Self(versions, matches: \.isCurrent) - } - - @_spi(Advanced) - public static func visionOS(_ versions: PartialRangeFrom>) -> Self { - Self([versions.lowerBound], matches: \.isCurrentOrPast) - } + let selector: IntrospectionSelector? + + private init( + _ versions: [PlatformViewVersion], + matches: (PlatformViewVersion) -> Bool + ) { + if let matchingVersion = versions.first(where: matches) { + self.selector = matchingVersion.selector ?? .default + } else { + self.selector = nil + } + } + + public static func iOS(_ versions: (iOSViewVersion)...) -> Self { + Self(versions, matches: \.isCurrent) + } + + @_spi(Advanced) + public static func iOS(_ versions: PartialRangeFrom>) -> Self { + Self([versions.lowerBound], matches: \.isCurrentOrPast) + } + + public static func tvOS(_ versions: (tvOSViewVersion)...) -> Self { + Self(versions, matches: \.isCurrent) + } + + @_spi(Advanced) + public static func tvOS(_ versions: PartialRangeFrom>) -> Self { + Self([versions.lowerBound], matches: \.isCurrentOrPast) + } + + public static func macOS(_ versions: (macOSViewVersion)...) -> Self { + Self(versions, matches: \.isCurrent) + } + + @_spi(Advanced) + public static func macOS(_ versions: PartialRangeFrom>) -> Self { + Self([versions.lowerBound], matches: \.isCurrentOrPast) + } + + public static func visionOS(_ versions: (visionOSViewVersion)...) -> Self { + Self(versions, matches: \.isCurrent) + } + + @_spi(Advanced) + public static func visionOS(_ versions: PartialRangeFrom>) -> Self { + Self([versions.lowerBound], matches: \.isCurrentOrPast) + } } public typealias iOSViewVersion = - PlatformViewVersion + PlatformViewVersion public typealias tvOSViewVersion = - PlatformViewVersion + PlatformViewVersion public typealias macOSViewVersion = - PlatformViewVersion + PlatformViewVersion public typealias visionOSViewVersion = - PlatformViewVersion + PlatformViewVersion @MainActor public enum PlatformViewVersion: Sendable { - @_spi(Internals) case available(Version, IntrospectionSelector?) - @_spi(Internals) case unavailable - - @_spi(Advanced) public init(for version: Version, selector: IntrospectionSelector? = nil) { - self = .available(version, selector) - } - - @_spi(Advanced) public static func unavailable(file: StaticString = #file, line: UInt = #line) -> Self { - let filePath = file.withUTF8Buffer { String(decoding: $0, as: UTF8.self) } - let fileName = URL(fileURLWithPath: filePath).lastPathComponent - print( - """ - If you're seeing this, someone forgot to mark \(fileName):\(line) as unavailable. - - This won't have any effect, but it should be disallowed altogether. - - Please report it upstream so we can properly fix it by using the following link: - - https://github.com/siteline/swiftui-introspect/issues/new?title=`\(fileName):\(line)`+should+be+marked+unavailable - """ - ) - return .unavailable - } - - private var version: Version? { - if case .available(let version, _) = self { - return version - } else { - return nil - } - } - - @MainActor - fileprivate var selector: IntrospectionSelector? { - if case .available(_, let selector) = self { - return selector - } else { - return nil - } - } - - fileprivate var isCurrent: Bool { - version?.isCurrent ?? false - } - - fileprivate var isCurrentOrPast: Bool { - version?.isCurrentOrPast ?? false - } + @_spi(Internals) case available(Version, IntrospectionSelector?) + @_spi(Internals) case unavailable + + @_spi(Advanced) public init(for version: Version, selector: IntrospectionSelector? = nil) { + self = .available(version, selector) + } + + @_spi(Advanced) public static func unavailable(file: StaticString = #file, line: UInt = #line) -> Self { + let filePath = file.withUTF8Buffer { String(decoding: $0, as: UTF8.self) } + let fileName = URL(fileURLWithPath: filePath).lastPathComponent + print( + """ + If you're seeing this, someone forgot to mark \(fileName):\(line) as unavailable. + + This won't have any effect, but it should be disallowed altogether. + + Please report it upstream so we can properly fix it by using the following link: + + https://github.com/siteline/swiftui-introspect/issues/new?title=`\(fileName):\(line)`+should+be+marked+unavailable + """ + ) + return .unavailable + } + + private var version: Version? { + if case .available(let version, _) = self { + return version + } else { + return nil + } + } + + @MainActor + fileprivate var selector: IntrospectionSelector? { + if case .available(_, let selector) = self { + return selector + } else { + return nil + } + } + + fileprivate var isCurrent: Bool { + version?.isCurrent ?? false + } + + fileprivate var isCurrentOrPast: Bool { + version?.isCurrentOrPast ?? false + } } // This conformance isn't meant to be used directly by the user, // it's only to satisfy requirements for forming ranges (e.g. `.v15...`). extension PlatformViewVersion: Comparable { - nonisolated public static func == (lhs: Self, rhs: Self) -> Bool { - true - } + nonisolated public static func == (lhs: Self, rhs: Self) -> Bool { + true + } - nonisolated public static func < (lhs: Self, rhs: Self) -> Bool { - true - } + nonisolated public static func < (lhs: Self, rhs: Self) -> Bool { + true + } } #endif diff --git a/Sources/Utils.swift b/Sources/Utils.swift index 7c1fc017..7848311e 100644 --- a/Sources/Utils.swift +++ b/Sources/Utils.swift @@ -1,28 +1,28 @@ postfix operator ~ postfix func ~ (lhs: LHS) -> T { - lhs as! T + lhs as! T } postfix func ~ (lhs: LHS?) -> T? { - lhs as? T + lhs as? T } func recursiveSequence(_ sequence: S, children: @escaping (S.Element) -> S) -> AnySequence { - AnySequence { - var mainIterator = sequence.makeIterator() - // Current iterator, or `nil` if all sequences are exhausted: - var iterator: AnyIterator? + AnySequence { + var mainIterator = sequence.makeIterator() + // Current iterator, or `nil` if all sequences are exhausted: + var iterator: AnyIterator? - return AnyIterator { - guard let iterator, let element = iterator.next() else { - if let element = mainIterator.next() { - iterator = recursiveSequence(children(element), children: children).makeIterator() - return element - } - return nil - } - return element - } - } + return AnyIterator { + guard let iterator, let element = iterator.next() else { + if let element = mainIterator.next() { + iterator = recursiveSequence(children(element), children: children).makeIterator() + return element + } + return nil + } + return element + } + } } diff --git a/Sources/ViewTypes/Button.swift b/Sources/ViewTypes/Button.swift index dda84a0c..c0cdbb66 100644 --- a/Sources/ViewTypes/Button.swift +++ b/Sources/ViewTypes/Button.swift @@ -29,20 +29,20 @@ public struct ButtonType: IntrospectableViewType {} #if !os(iOS) && !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == ButtonType { - public static var button: Self { .init() } + public static var button: Self { .init() } } #if canImport(AppKit) && !targetEnvironment(macCatalyst) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ColorPicker.swift b/Sources/ViewTypes/ColorPicker.swift index cfb3e7f0..28788ba4 100644 --- a/Sources/ViewTypes/ColorPicker.swift +++ b/Sources/ViewTypes/ColorPicker.swift @@ -53,7 +53,7 @@ public struct ColorPickerType: IntrospectableViewType {} #if !os(tvOS) extension IntrospectableViewType where Self == ColorPickerType { - public static var colorPicker: Self { .init() } + public static var colorPicker: Self { .init() } } #if canImport(UIKit) @@ -61,35 +61,35 @@ public import UIKit @available(iOS 14, *) extension iOSViewVersion { - @available(*, unavailable, message: "ColorPicker isn't available on iOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: "ColorPicker isn't available on iOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } @available(iOS 14, *) extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit @available(macOS 11, *) extension macOSViewVersion { - @available(*, unavailable, message: "ColorPicker isn't available on macOS 10.15") - public static let v10_15 = Self.unavailable() - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: "ColorPicker isn't available on macOS 10.15") + public static let v10_15 = Self.unavailable() + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/DatePicker.swift b/Sources/ViewTypes/DatePicker.swift index 271f1687..2645b50b 100644 --- a/Sources/ViewTypes/DatePicker.swift +++ b/Sources/ViewTypes/DatePicker.swift @@ -51,38 +51,38 @@ public struct DatePickerType: IntrospectableViewType {} #if !os(tvOS) extension IntrospectableViewType where Self == DatePickerType { - public static var datePicker: Self { .init() } + public static var datePicker: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/DatePickerWithCompactStyle.swift b/Sources/ViewTypes/DatePickerWithCompactStyle.swift index d468c30c..0e9d50c0 100644 --- a/Sources/ViewTypes/DatePickerWithCompactStyle.swift +++ b/Sources/ViewTypes/DatePickerWithCompactStyle.swift @@ -53,48 +53,48 @@ /// } /// ``` public struct DatePickerWithCompactStyleType: IntrospectableViewType { - public enum Style: Sendable { - case compact - } + public enum Style: Sendable { + case compact + } } #if !os(tvOS) extension IntrospectableViewType where Self == DatePickerWithCompactStyleType { - public static func datePicker(style: Self.Style) -> Self { .init() } + public static func datePicker(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: ".datePickerStyle(.compact) isn't available on iOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".datePickerStyle(.compact) isn't available on iOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) && !targetEnvironment(macCatalyst) public import AppKit extension macOSViewVersion { - @available(*, unavailable, message: ".datePickerStyle(.compact) isn't available on macOS 10.15") - public static let v10_15 = Self.unavailable() - public static let v10_15_4 = Self(for: .v10_15_4) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".datePickerStyle(.compact) isn't available on macOS 10.15") + public static let v10_15 = Self.unavailable() + public static let v10_15_4 = Self(for: .v10_15_4) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/DatePickerWithFieldStyle.swift b/Sources/ViewTypes/DatePickerWithFieldStyle.swift index 7461fbba..8eb1070a 100644 --- a/Sources/ViewTypes/DatePickerWithFieldStyle.swift +++ b/Sources/ViewTypes/DatePickerWithFieldStyle.swift @@ -29,27 +29,27 @@ /// /// Not available. public struct DatePickerWithFieldStyleType: IntrospectableViewType { - public enum Style: Sendable { - case field - } + public enum Style: Sendable { + case field + } } #if !os(iOS) && !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == DatePickerWithFieldStyleType { - public static func datePicker(style: Self.Style) -> Self { .init() } + public static func datePicker(style: Self.Style) -> Self { .init() } } #if canImport(AppKit) && !targetEnvironment(macCatalyst) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/DatePickerWithGraphicalStyle.swift b/Sources/ViewTypes/DatePickerWithGraphicalStyle.swift index d9deb75b..04036fc8 100644 --- a/Sources/ViewTypes/DatePickerWithGraphicalStyle.swift +++ b/Sources/ViewTypes/DatePickerWithGraphicalStyle.swift @@ -53,46 +53,46 @@ /// } /// ``` public struct DatePickerWithGraphicalStyleType: IntrospectableViewType { - public enum Style: Sendable { - case graphical - } + public enum Style: Sendable { + case graphical + } } #if !os(tvOS) extension IntrospectableViewType where Self == DatePickerWithGraphicalStyleType { - public static func datePicker(style: Self.Style) -> Self { .init() } + public static func datePicker(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: ".datePickerStyle(.graphical) isn't available on iOS 13") - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".datePickerStyle(.graphical) isn't available on iOS 13") + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) && !targetEnvironment(macCatalyst) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/DatePickerWithStepperFieldStyle.swift b/Sources/ViewTypes/DatePickerWithStepperFieldStyle.swift index 0c9cb709..61caf041 100644 --- a/Sources/ViewTypes/DatePickerWithStepperFieldStyle.swift +++ b/Sources/ViewTypes/DatePickerWithStepperFieldStyle.swift @@ -29,27 +29,27 @@ /// /// Not available. public struct DatePickerWithStepperFieldStyleType: IntrospectableViewType { - public enum Style: Sendable { - case stepperField - } + public enum Style: Sendable { + case stepperField + } } #if !os(iOS) && !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == DatePickerWithStepperFieldStyleType { - public static func datePicker(style: Self.Style) -> Self { .init() } + public static func datePicker(style: Self.Style) -> Self { .init() } } #if canImport(AppKit) && !targetEnvironment(macCatalyst) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/DatePickerWithWheelStyle.swift b/Sources/ViewTypes/DatePickerWithWheelStyle.swift index ac5746bc..a2df5126 100644 --- a/Sources/ViewTypes/DatePickerWithWheelStyle.swift +++ b/Sources/ViewTypes/DatePickerWithWheelStyle.swift @@ -41,33 +41,33 @@ /// } /// ``` public struct DatePickerWithWheelStyleType: IntrospectableViewType { - public enum Style: Sendable { - case wheel - } + public enum Style: Sendable { + case wheel + } } #if !os(tvOS) && !os(macOS) extension IntrospectableViewType where Self == DatePickerWithWheelStyleType { - public static func datePicker(style: Self.Style) -> Self { .init() } + public static func datePicker(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/Form.swift b/Sources/ViewTypes/Form.swift index f7786e7a..f1266688 100644 --- a/Sources/ViewTypes/Form.swift +++ b/Sources/ViewTypes/Form.swift @@ -62,39 +62,39 @@ public struct FormType: IntrospectableViewType {} #if !os(macOS) extension IntrospectableViewType where Self == FormType { - public static var form: Self { .init() } + public static var form: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) } extension iOSViewVersion { - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/FormWithGroupedStyle.swift b/Sources/ViewTypes/FormWithGroupedStyle.swift index 2d2b1913..705b4357 100644 --- a/Sources/ViewTypes/FormWithGroupedStyle.swift +++ b/Sources/ViewTypes/FormWithGroupedStyle.swift @@ -73,66 +73,66 @@ /// } /// ``` public struct FormWithGroupedStyleType: IntrospectableViewType { - public enum Style: Sendable { - case grouped - } + public enum Style: Sendable { + case grouped + } } extension IntrospectableViewType where Self == FormWithGroupedStyleType { - public static func form(style: Self.Style) -> Self { .init() } + public static func form(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: ".formStyle(.grouped) isn't available on iOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: ".formStyle(.grouped) isn't available on iOS 14") - public static let v14 = Self.unavailable() - @available(*, unavailable, message: ".formStyle(.grouped) isn't available on iOS 15") - public static let v15 = Self.unavailable() + @available(*, unavailable, message: ".formStyle(.grouped) isn't available on iOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: ".formStyle(.grouped) isn't available on iOS 14") + public static let v14 = Self.unavailable() + @available(*, unavailable, message: ".formStyle(.grouped) isn't available on iOS 15") + public static let v15 = Self.unavailable() } extension iOSViewVersion { - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - @available(*, unavailable, message: ".formStyle(.grouped) isn't available on tvOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: ".formStyle(.grouped) isn't available on tvOS 14") - public static let v14 = Self.unavailable() - @available(*, unavailable, message: ".formStyle(.grouped) isn't available on tvOS 15") - public static let v15 = Self.unavailable() - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".formStyle(.grouped) isn't available on tvOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: ".formStyle(.grouped) isn't available on tvOS 14") + public static let v14 = Self.unavailable() + @available(*, unavailable, message: ".formStyle(.grouped) isn't available on tvOS 15") + public static let v15 = Self.unavailable() + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - @available(*, unavailable, message: ".formStyle(.grouped) isn't available on macOS 10.15") - public static let v10_15 = Self.unavailable() - @available(*, unavailable, message: ".formStyle(.grouped) isn't available on macOS 11") - public static let v11 = Self.unavailable() - @available(*, unavailable, message: ".formStyle(.grouped) isn't available on macOS 12") - public static let v12 = Self.unavailable() - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".formStyle(.grouped) isn't available on macOS 10.15") + public static let v10_15 = Self.unavailable() + @available(*, unavailable, message: ".formStyle(.grouped) isn't available on macOS 11") + public static let v11 = Self.unavailable() + @available(*, unavailable, message: ".formStyle(.grouped) isn't available on macOS 12") + public static let v12 = Self.unavailable() + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/FullScreenCover.swift b/Sources/ViewTypes/FullScreenCover.swift index 5b2351df..983e7d82 100644 --- a/Sources/ViewTypes/FullScreenCover.swift +++ b/Sources/ViewTypes/FullScreenCover.swift @@ -59,55 +59,55 @@ /// } /// ``` public struct FullScreenCoverType: IntrospectableViewType { - public var scope: IntrospectionScope { .ancestor } + public var scope: IntrospectionScope { .ancestor } } #if !os(macOS) extension IntrospectableViewType where Self == FullScreenCoverType { - public static var fullScreenCover: Self { .init() } + public static var fullScreenCover: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: ".fullScreenCover isn't available on iOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + @available(*, unavailable, message: ".fullScreenCover isn't available on iOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UIViewController.self, selector: { $0.presentationController }) - } + private static var selector: IntrospectionSelector { + .from(UIViewController.self, selector: { $0.presentationController }) + } } extension tvOSViewVersion { - @available(*, unavailable, message: ".fullScreenCover isn't available on tvOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + @available(*, unavailable, message: ".fullScreenCover isn't available on tvOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UIViewController.self, selector: { $0.presentationController }) - } + private static var selector: IntrospectionSelector { + .from(UIViewController.self, selector: { $0.presentationController }) + } } extension visionOSViewVersion { - public static let v1 = Self(for: .v1, selector: selector) - public static let v2 = Self(for: .v2, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v1 = Self(for: .v1, selector: selector) + public static let v2 = Self(for: .v2, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UIViewController.self, selector: { $0.presentationController }) - } + private static var selector: IntrospectionSelector { + .from(UIViewController.self, selector: { $0.presentationController }) + } } #endif #endif diff --git a/Sources/ViewTypes/List.swift b/Sources/ViewTypes/List.swift index 1c1e6112..c78f66ea 100644 --- a/Sources/ViewTypes/List.swift +++ b/Sources/ViewTypes/List.swift @@ -72,58 +72,58 @@ /// } /// ``` public struct ListType: IntrospectableViewType { - public enum Style: Sendable { - case plain - } + public enum Style: Sendable { + case plain + } } extension IntrospectableViewType where Self == ListType { - public static var list: Self { .init() } - public static func list(style: Self.Style) -> Self { .init() } + public static var list: Self { .init() } + public static func list(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) } extension iOSViewVersion { - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ListCell.swift b/Sources/ViewTypes/ListCell.swift index 0d8229e3..af41b2ba 100644 --- a/Sources/ViewTypes/ListCell.swift +++ b/Sources/ViewTypes/ListCell.swift @@ -72,55 +72,55 @@ /// } /// ``` public struct ListCellType: IntrospectableViewType { - public var scope: IntrospectionScope { .ancestor } + public var scope: IntrospectionScope { .ancestor } } extension IntrospectableViewType where Self == ListCellType { - public static var listCell: Self { .init() } + public static var listCell: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) } extension iOSViewVersion { - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ListWithBorderedStyle.swift b/Sources/ViewTypes/ListWithBorderedStyle.swift index d909ded6..84d409db 100644 --- a/Sources/ViewTypes/ListWithBorderedStyle.swift +++ b/Sources/ViewTypes/ListWithBorderedStyle.swift @@ -31,29 +31,29 @@ /// /// Not available. public struct ListWithBorderedStyleType: IntrospectableViewType { - public enum Style: Sendable { - case bordered - } + public enum Style: Sendable { + case bordered + } } #if !os(iOS) && !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == ListWithBorderedStyleType { - public static func list(style: Self.Style) -> Self { .init() } + public static func list(style: Self.Style) -> Self { .init() } } #if canImport(AppKit) && !targetEnvironment(macCatalyst) public import AppKit extension macOSViewVersion { - @available(*, unavailable, message: ".listStyle(.insetGrouped) isn't available on macOS 10.15") - public static let v10_15 = Self.unavailable() - @available(*, unavailable, message: ".listStyle(.insetGrouped) isn't available on macOS 11") - public static let v11 = Self.unavailable() - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".listStyle(.insetGrouped) isn't available on macOS 10.15") + public static let v10_15 = Self.unavailable() + @available(*, unavailable, message: ".listStyle(.insetGrouped) isn't available on macOS 11") + public static let v11 = Self.unavailable() + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ListWithGroupedStyle.swift b/Sources/ViewTypes/ListWithGroupedStyle.swift index 1c4f7725..5e93fd0b 100644 --- a/Sources/ViewTypes/ListWithGroupedStyle.swift +++ b/Sources/ViewTypes/ListWithGroupedStyle.swift @@ -62,46 +62,46 @@ /// } /// ``` public struct ListWithGroupedStyleType: IntrospectableViewType { - public enum Style: Sendable { - case grouped - } + public enum Style: Sendable { + case grouped + } } #if !os(macOS) extension IntrospectableViewType where Self == ListWithGroupedStyleType { - public static func list(style: Self.Style) -> Self { .init() } + public static func list(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) } extension iOSViewVersion { - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ListWithInsetGroupedStyle.swift b/Sources/ViewTypes/ListWithInsetGroupedStyle.swift index 3d01a512..d65f9df1 100644 --- a/Sources/ViewTypes/ListWithInsetGroupedStyle.swift +++ b/Sources/ViewTypes/ListWithInsetGroupedStyle.swift @@ -48,37 +48,37 @@ /// } /// ``` public struct ListWithInsetGroupedStyleType: IntrospectableViewType { - public enum Style: Sendable { - case insetGrouped - } + public enum Style: Sendable { + case insetGrouped + } } #if !os(tvOS) && !os(macOS) extension IntrospectableViewType where Self == ListWithInsetGroupedStyleType { - public static func list(style: Self.Style) -> Self { .init() } + public static func list(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: ".listStyle(.insetGrouped) isn't available on iOS 13") - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) + @available(*, unavailable, message: ".listStyle(.insetGrouped) isn't available on iOS 13") + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) } extension iOSViewVersion { - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ListWithInsetStyle.swift b/Sources/ViewTypes/ListWithInsetStyle.swift index a142c34e..c4cbdec5 100644 --- a/Sources/ViewTypes/ListWithInsetStyle.swift +++ b/Sources/ViewTypes/ListWithInsetStyle.swift @@ -62,50 +62,50 @@ /// } /// ``` public struct ListWithInsetStyleType: IntrospectableViewType { - public enum Style: Sendable { - case inset - } + public enum Style: Sendable { + case inset + } } #if !os(tvOS) extension IntrospectableViewType where Self == ListWithInsetStyleType { - public static func list(style: Self.Style) -> Self { .init() } + public static func list(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: ".listStyle(.inset) isn't available on iOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) + @available(*, unavailable, message: ".listStyle(.inset) isn't available on iOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) } extension iOSViewVersion { - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - @available(*, unavailable, message: ".listStyle(.inset) isn't available on macOS 10.15") - public static let v10_15 = Self.unavailable() - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".listStyle(.inset) isn't available on macOS 10.15") + public static let v10_15 = Self.unavailable() + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ListWithSidebarStyle.swift b/Sources/ViewTypes/ListWithSidebarStyle.swift index e5951bdd..e3fa0e29 100644 --- a/Sources/ViewTypes/ListWithSidebarStyle.swift +++ b/Sources/ViewTypes/ListWithSidebarStyle.swift @@ -62,49 +62,49 @@ /// } /// ``` public struct ListWithSidebarStyleType: IntrospectableViewType { - public enum Style: Sendable { - case sidebar - } + public enum Style: Sendable { + case sidebar + } } #if !os(tvOS) extension IntrospectableViewType where Self == ListWithSidebarStyleType { - public static func list(style: Self.Style) -> Self { .init() } + public static func list(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: ".listStyle(.sidebar) isn't available on iOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) + @available(*, unavailable, message: ".listStyle(.sidebar) isn't available on iOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) } extension iOSViewVersion { - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/Map.swift b/Sources/ViewTypes/Map.swift index 39f80cea..bbdb8480 100644 --- a/Sources/ViewTypes/Map.swift +++ b/Sources/ViewTypes/Map.swift @@ -66,46 +66,46 @@ public struct MapType: IntrospectableViewType {} public import MapKit extension IntrospectableViewType where Self == MapType { - public static var map: Self { .init() } + public static var map: Self { .init() } } extension iOSViewVersion { - @available(*, unavailable, message: "Map isn't available on iOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: "Map isn't available on iOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - @available(*, unavailable, message: "Map isn't available on tvOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: "Map isn't available on tvOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension macOSViewVersion { - @available(*, unavailable, message: "Map isn't available on macOS 10.15") - public static let v10_15 = Self.unavailable() - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: "Map isn't available on macOS 10.15") + public static let v10_15 = Self.unavailable() + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/NavigationSplitView.swift b/Sources/ViewTypes/NavigationSplitView.swift index 3efe3dd5..4e9ce110 100644 --- a/Sources/ViewTypes/NavigationSplitView.swift +++ b/Sources/ViewTypes/NavigationSplitView.swift @@ -71,74 +71,74 @@ public struct NavigationSplitViewType: IntrospectableViewType {} extension IntrospectableViewType where Self == NavigationSplitViewType { - public static var navigationSplitView: Self { .init() } + public static var navigationSplitView: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: "NavigationSplitView isn't available on iOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: "NavigationSplitView isn't available on iOS 14") - public static let v14 = Self.unavailable() - @available(*, unavailable, message: "NavigationSplitView isn't available on iOS 15") - public static let v15 = Self.unavailable() + @available(*, unavailable, message: "NavigationSplitView isn't available on iOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: "NavigationSplitView isn't available on iOS 14") + public static let v14 = Self.unavailable() + @available(*, unavailable, message: "NavigationSplitView isn't available on iOS 15") + public static let v15 = Self.unavailable() - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.splitViewController } - } + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.splitViewController } + } } extension tvOSViewVersion { - @available(*, unavailable, message: "NavigationSplitView isn't available on tvOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: "NavigationSplitView isn't available on tvOS 14") - public static let v14 = Self.unavailable() - @available(*, unavailable, message: "NavigationSplitView isn't available on tvOS 15") - public static let v15 = Self.unavailable() + @available(*, unavailable, message: "NavigationSplitView isn't available on tvOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: "NavigationSplitView isn't available on tvOS 14") + public static let v14 = Self.unavailable() + @available(*, unavailable, message: "NavigationSplitView isn't available on tvOS 15") + public static let v15 = Self.unavailable() - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - @available(*, unavailable, message: "NavigationSplitView isn't backed by UIKit since tvOS 18") - public static let v18 = Self.unavailable() - @available(*, unavailable, message: "NavigationSplitView isn't backed by UIKit since tvOS 18") - public static let v26 = Self.unavailable() + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + @available(*, unavailable, message: "NavigationSplitView isn't backed by UIKit since tvOS 18") + public static let v18 = Self.unavailable() + @available(*, unavailable, message: "NavigationSplitView isn't backed by UIKit since tvOS 18") + public static let v26 = Self.unavailable() - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.navigationController } - } + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.navigationController } + } } extension visionOSViewVersion { - public static let v1 = Self(for: .v1, selector: selector) - public static let v2 = Self(for: .v2, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v1 = Self(for: .v1, selector: selector) + public static let v2 = Self(for: .v2, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.splitViewController } - } + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.splitViewController } + } } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - @available(*, unavailable, message: "NavigationSplitView isn't available on macOS 10.15") - public static let v10_15 = Self.unavailable() - @available(*, unavailable, message: "NavigationSplitView isn't available on macOS 11") - public static let v11 = Self.unavailable() - @available(*, unavailable, message: "NavigationSplitView isn't available on macOS 12") - public static let v12 = Self.unavailable() + @available(*, unavailable, message: "NavigationSplitView isn't available on macOS 10.15") + public static let v10_15 = Self.unavailable() + @available(*, unavailable, message: "NavigationSplitView isn't available on macOS 11") + public static let v11 = Self.unavailable() + @available(*, unavailable, message: "NavigationSplitView isn't available on macOS 12") + public static let v12 = Self.unavailable() - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/NavigationStack.swift b/Sources/ViewTypes/NavigationStack.swift index d18eba8c..3b1d342b 100644 --- a/Sources/ViewTypes/NavigationStack.swift +++ b/Sources/ViewTypes/NavigationStack.swift @@ -52,56 +52,56 @@ public struct NavigationStackType: IntrospectableViewType {} extension IntrospectableViewType where Self == NavigationStackType { - public static var navigationStack: Self { .init() } + public static var navigationStack: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: "NavigationStack isn't available on iOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: "NavigationStack isn't available on iOS 14") - public static let v14 = Self.unavailable() - @available(*, unavailable, message: "NavigationStack isn't available on iOS 15") - public static let v15 = Self.unavailable() + @available(*, unavailable, message: "NavigationStack isn't available on iOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: "NavigationStack isn't available on iOS 14") + public static let v14 = Self.unavailable() + @available(*, unavailable, message: "NavigationStack isn't available on iOS 15") + public static let v15 = Self.unavailable() - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.navigationController } - } + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.navigationController } + } } extension tvOSViewVersion { - @available(*, unavailable, message: "NavigationStack isn't available on tvOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: "NavigationStack isn't available on tvOS 14") - public static let v14 = Self.unavailable() - @available(*, unavailable, message: "NavigationStack isn't available on tvOS 15") - public static let v15 = Self.unavailable() + @available(*, unavailable, message: "NavigationStack isn't available on tvOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: "NavigationStack isn't available on tvOS 14") + public static let v14 = Self.unavailable() + @available(*, unavailable, message: "NavigationStack isn't available on tvOS 15") + public static let v15 = Self.unavailable() - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.navigationController } - } + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.navigationController } + } } extension visionOSViewVersion { - public static let v1 = Self(for: .v1, selector: selector) - public static let v2 = Self(for: .v2, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v1 = Self(for: .v1, selector: selector) + public static let v2 = Self(for: .v2, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.navigationController } - } + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.navigationController } + } } #endif #endif diff --git a/Sources/ViewTypes/NavigationViewWithColumnsStyle.swift b/Sources/ViewTypes/NavigationViewWithColumnsStyle.swift index 9b681573..5d32f772 100644 --- a/Sources/ViewTypes/NavigationViewWithColumnsStyle.swift +++ b/Sources/ViewTypes/NavigationViewWithColumnsStyle.swift @@ -65,66 +65,66 @@ /// } /// ``` public struct NavigationViewWithColumnsStyleType: IntrospectableViewType { - public enum Style: Sendable { - case columns - } + public enum Style: Sendable { + case columns + } } extension IntrospectableViewType where Self == NavigationViewWithColumnsStyleType { - public static func navigationView(style: Self.Style) -> Self { .init() } + public static func navigationView(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13, selector: selector) - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v13 = Self(for: .v13, selector: selector) + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.splitViewController } - } + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.splitViewController } + } } extension tvOSViewVersion { - public static let v13 = Self(for: .v13, selector: selector) - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v13 = Self(for: .v13, selector: selector) + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.navigationController } - } + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.navigationController } + } } extension visionOSViewVersion { - public static let v1 = Self(for: .v1, selector: selector) - public static let v2 = Self(for: .v2, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v1 = Self(for: .v1, selector: selector) + public static let v2 = Self(for: .v2, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.splitViewController } - } + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.splitViewController } + } } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/NavigationViewWithStackStyle.swift b/Sources/ViewTypes/NavigationViewWithStackStyle.swift index 7d888aab..a9a8b0dd 100644 --- a/Sources/ViewTypes/NavigationViewWithStackStyle.swift +++ b/Sources/ViewTypes/NavigationViewWithStackStyle.swift @@ -53,54 +53,54 @@ /// } /// ``` public struct NavigationViewWithStackStyleType: IntrospectableViewType { - public enum Style: Sendable { - case stack - } + public enum Style: Sendable { + case stack + } } extension IntrospectableViewType where Self == NavigationViewWithStackStyleType { - public static func navigationView(style: Self.Style) -> Self { .init() } + public static func navigationView(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13, selector: selector) - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v13 = Self(for: .v13, selector: selector) + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.navigationController } - } + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.navigationController } + } } extension tvOSViewVersion { - public static let v13 = Self(for: .v13, selector: selector) - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v13 = Self(for: .v13, selector: selector) + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.navigationController } - } + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.navigationController } + } } extension visionOSViewVersion { - public static let v1 = Self(for: .v1, selector: selector) - public static let v2 = Self(for: .v2, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v1 = Self(for: .v1, selector: selector) + public static let v2 = Self(for: .v2, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.navigationController } - } + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.navigationController } + } } #endif #endif diff --git a/Sources/ViewTypes/PageControl.swift b/Sources/ViewTypes/PageControl.swift index 2d280aa8..9de589af 100644 --- a/Sources/ViewTypes/PageControl.swift +++ b/Sources/ViewTypes/PageControl.swift @@ -58,38 +58,38 @@ public struct PageControlType: IntrospectableViewType {} extension IntrospectableViewType where Self == PageControlType { - public static var pageControl: Self { .init() } + public static var pageControl: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: ".tabViewStyle(.page) isn't available on iOS 13") - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".tabViewStyle(.page) isn't available on iOS 13") + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - @available(*, unavailable, message: ".tabViewStyle(.page) isn't available on tvOS 13") - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".tabViewStyle(.page) isn't available on tvOS 13") + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/PickerWithMenuStyle.swift b/Sources/ViewTypes/PickerWithMenuStyle.swift index 96ac5b4e..f5837a2e 100644 --- a/Sources/ViewTypes/PickerWithMenuStyle.swift +++ b/Sources/ViewTypes/PickerWithMenuStyle.swift @@ -33,28 +33,28 @@ /// /// Not available. public struct PickerWithMenuStyleType: IntrospectableViewType { - public enum Style: Sendable { - case menu - } + public enum Style: Sendable { + case menu + } } #if !os(iOS) && !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == PickerWithMenuStyleType { - public static func picker(style: Self.Style) -> Self { .init() } + public static func picker(style: Self.Style) -> Self { .init() } } #if canImport(AppKit) && !targetEnvironment(macCatalyst) public import AppKit extension macOSViewVersion { - @available(*, unavailable, message: ".pickerStyle(.menu) isn't available on macOS 10.15") - public static let v10_15 = Self.unavailable() - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".pickerStyle(.menu) isn't available on macOS 10.15") + public static let v10_15 = Self.unavailable() + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/PickerWithSegmentedStyle.swift b/Sources/ViewTypes/PickerWithSegmentedStyle.swift index f567693c..dd77dcfa 100644 --- a/Sources/ViewTypes/PickerWithSegmentedStyle.swift +++ b/Sources/ViewTypes/PickerWithSegmentedStyle.swift @@ -81,54 +81,54 @@ /// } /// ``` public struct PickerWithSegmentedStyleType: IntrospectableViewType { - public enum Style: Sendable { - case segmented - } + public enum Style: Sendable { + case segmented + } } extension IntrospectableViewType where Self == PickerWithSegmentedStyleType { - public static func picker(style: Self.Style) -> Self { .init() } + public static func picker(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/PickerWithWheelStyle.swift b/Sources/ViewTypes/PickerWithWheelStyle.swift index 34747584..5b0a8e32 100644 --- a/Sources/ViewTypes/PickerWithWheelStyle.swift +++ b/Sources/ViewTypes/PickerWithWheelStyle.swift @@ -49,33 +49,33 @@ /// } /// ``` public struct PickerWithWheelStyleType: IntrospectableViewType { - public enum Style: Sendable { - case wheel - } + public enum Style: Sendable { + case wheel + } } #if !os(tvOS) && !os(macOS) extension IntrospectableViewType where Self == PickerWithWheelStyleType { - public static func picker(style: Self.Style) -> Self { .init() } + public static func picker(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/Popover.swift b/Sources/ViewTypes/Popover.swift index 6204476a..c913a5d2 100644 --- a/Sources/ViewTypes/Popover.swift +++ b/Sources/ViewTypes/Popover.swift @@ -45,39 +45,39 @@ /// } /// ``` public struct PopoverType: IntrospectableViewType { - public var scope: IntrospectionScope { .ancestor } + public var scope: IntrospectionScope { .ancestor } } #if !os(tvOS) && !os(macOS) extension IntrospectableViewType where Self == PopoverType { - public static var popover: Self { .init() } + public static var popover: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13, selector: selector) - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v13 = Self(for: .v13, selector: selector) + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UIViewController.self, selector: { $0.popoverPresentationController }) - } + private static var selector: IntrospectionSelector { + .from(UIViewController.self, selector: { $0.popoverPresentationController }) + } } extension visionOSViewVersion { - public static let v1 = Self(for: .v1, selector: selector) - public static let v2 = Self(for: .v2, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v1 = Self(for: .v1, selector: selector) + public static let v2 = Self(for: .v2, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UIViewController.self, selector: { $0.popoverPresentationController }) - } + private static var selector: IntrospectionSelector { + .from(UIViewController.self, selector: { $0.popoverPresentationController }) + } } #endif #endif diff --git a/Sources/ViewTypes/ProgressViewWithCircularStyle.swift b/Sources/ViewTypes/ProgressViewWithCircularStyle.swift index 168a075a..0735ccc0 100644 --- a/Sources/ViewTypes/ProgressViewWithCircularStyle.swift +++ b/Sources/ViewTypes/ProgressViewWithCircularStyle.swift @@ -57,57 +57,57 @@ /// } /// ``` public struct ProgressViewWithCircularStyleType: IntrospectableViewType { - public enum Style: Sendable { - case circular - } + public enum Style: Sendable { + case circular + } } extension IntrospectableViewType where Self == ProgressViewWithCircularStyleType { - public static func progressView(style: Self.Style) -> Self { .init() } + public static func progressView(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: ".progressViewStyle(.circular) isn't available on iOS 13") - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".progressViewStyle(.circular) isn't available on iOS 13") + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - @available(*, unavailable, message: ".progressViewStyle(.circular) isn't available on tvOS 13") - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".progressViewStyle(.circular) isn't available on tvOS 13") + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - @available(*, unavailable, message: ".progressViewStyle(.circular) isn't available on macOS 10.15") - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".progressViewStyle(.circular) isn't available on macOS 10.15") + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ProgressViewWithLinearStyle.swift b/Sources/ViewTypes/ProgressViewWithLinearStyle.swift index 2f20bfbd..39219d35 100644 --- a/Sources/ViewTypes/ProgressViewWithLinearStyle.swift +++ b/Sources/ViewTypes/ProgressViewWithLinearStyle.swift @@ -57,57 +57,57 @@ /// } /// ``` public struct ProgressViewWithLinearStyleType: IntrospectableViewType { - public enum Style: Sendable { - case linear - } + public enum Style: Sendable { + case linear + } } extension IntrospectableViewType where Self == ProgressViewWithLinearStyleType { - public static func progressView(style: Self.Style) -> Self { .init() } + public static func progressView(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: ".progressViewStyle(.linear) isn't available on iOS 13") - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".progressViewStyle(.linear) isn't available on iOS 13") + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - @available(*, unavailable, message: ".progressViewStyle(.linear) isn't available on tvOS 13") - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".progressViewStyle(.linear) isn't available on tvOS 13") + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - @available(*, unavailable, message: ".progressViewStyle(.linear) isn't available on macOS 10.15") - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".progressViewStyle(.linear) isn't available on macOS 10.15") + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ScrollView.swift b/Sources/ViewTypes/ScrollView.swift index 26d2c1fb..e01a0cea 100644 --- a/Sources/ViewTypes/ScrollView.swift +++ b/Sources/ViewTypes/ScrollView.swift @@ -63,48 +63,48 @@ public struct ScrollViewType: IntrospectableViewType {} extension IntrospectableViewType where Self == ScrollViewType { - public static var scrollView: Self { .init() } + public static var scrollView: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/SearchField.swift b/Sources/ViewTypes/SearchField.swift index c7245a7b..334c2d59 100644 --- a/Sources/ViewTypes/SearchField.swift +++ b/Sources/ViewTypes/SearchField.swift @@ -97,58 +97,58 @@ public struct SearchFieldType: IntrospectableViewType {} extension IntrospectableViewType where Self == SearchFieldType { - public static var searchField: Self { .init() } + public static var searchField: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: ".searchable isn't available on iOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: ".searchable isn't available on iOS 14") - public static let v14 = Self.unavailable() - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + @available(*, unavailable, message: ".searchable isn't available on iOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: ".searchable isn't available on iOS 14") + public static let v14 = Self.unavailable() + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UINavigationController.self) { - $0.viewIfLoaded?.allDescendants.lazy.compactMap { $0 as? UISearchBar }.first - } - } + private static var selector: IntrospectionSelector { + .from(UINavigationController.self) { + $0.viewIfLoaded?.allDescendants.lazy.compactMap { $0 as? UISearchBar }.first + } + } } extension tvOSViewVersion { - @available(*, unavailable, message: ".searchable isn't available on tvOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: ".searchable isn't available on tvOS 14") - public static let v14 = Self.unavailable() - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + @available(*, unavailable, message: ".searchable isn't available on tvOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: ".searchable isn't available on tvOS 14") + public static let v14 = Self.unavailable() + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UINavigationController.self) { - $0.viewIfLoaded?.allDescendants.lazy.compactMap { $0 as? UISearchBar }.first - } - } + private static var selector: IntrospectionSelector { + .from(UINavigationController.self) { + $0.viewIfLoaded?.allDescendants.lazy.compactMap { $0 as? UISearchBar }.first + } + } } extension visionOSViewVersion { - public static let v1 = Self(for: .v1, selector: selector) - public static let v2 = Self(for: .v2, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v1 = Self(for: .v1, selector: selector) + public static let v2 = Self(for: .v2, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UINavigationController.self) { - $0.viewIfLoaded?.allDescendants.lazy.compactMap { $0 as? UISearchBar }.first - } - } + private static var selector: IntrospectionSelector { + .from(UINavigationController.self) { + $0.viewIfLoaded?.allDescendants.lazy.compactMap { $0 as? UISearchBar }.first + } + } } #endif #endif diff --git a/Sources/ViewTypes/SecureField.swift b/Sources/ViewTypes/SecureField.swift index 3a41247b..209f2fa0 100644 --- a/Sources/ViewTypes/SecureField.swift +++ b/Sources/ViewTypes/SecureField.swift @@ -63,48 +63,48 @@ public struct SecureFieldType: IntrospectableViewType {} extension IntrospectableViewType where Self == SecureFieldType { - public static var secureField: Self { .init() } + public static var secureField: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/Sheet.swift b/Sources/ViewTypes/Sheet.swift index 91600433..c3ad857b 100644 --- a/Sources/ViewTypes/Sheet.swift +++ b/Sources/ViewTypes/Sheet.swift @@ -59,74 +59,74 @@ /// } /// ``` public struct SheetType: IntrospectableViewType { - public var scope: IntrospectionScope { .ancestor } + public var scope: IntrospectionScope { .ancestor } } #if !os(macOS) extension IntrospectableViewType where Self == SheetType { - public static var sheet: Self { .init() } + public static var sheet: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13, selector: selector) - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v13 = Self(for: .v13, selector: selector) + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UIViewController.self, selector: { $0.presentationController }) - } + private static var selector: IntrospectionSelector { + .from(UIViewController.self, selector: { $0.presentationController }) + } } #if !os(tvOS) @available(iOS 15, *) extension iOSViewVersion { - @_disfavoredOverload - public static let v15 = Self(for: .v15, selector: selector) - @_disfavoredOverload - public static let v16 = Self(for: .v16, selector: selector) - @_disfavoredOverload - public static let v17 = Self(for: .v17, selector: selector) - @_disfavoredOverload - public static let v18 = Self(for: .v18, selector: selector) - @_disfavoredOverload - public static let v26 = Self(for: .v26, selector: selector) + @_disfavoredOverload + public static let v15 = Self(for: .v15, selector: selector) + @_disfavoredOverload + public static let v16 = Self(for: .v16, selector: selector) + @_disfavoredOverload + public static let v17 = Self(for: .v17, selector: selector) + @_disfavoredOverload + public static let v18 = Self(for: .v18, selector: selector) + @_disfavoredOverload + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UIViewController.self, selector: { $0.sheetPresentationController }) - } + private static var selector: IntrospectionSelector { + .from(UIViewController.self, selector: { $0.sheetPresentationController }) + } } @available(iOS 15, *) extension visionOSViewVersion { - public static let v1 = Self(for: .v1, selector: selector) - public static let v2 = Self(for: .v2, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v1 = Self(for: .v1, selector: selector) + public static let v2 = Self(for: .v2, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UIViewController.self, selector: { $0.sheetPresentationController }) - } + private static var selector: IntrospectionSelector { + .from(UIViewController.self, selector: { $0.sheetPresentationController }) + } } #endif extension tvOSViewVersion { - public static let v13 = Self(for: .v13, selector: selector) - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v13 = Self(for: .v13, selector: selector) + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UIViewController.self, selector: { $0.presentationController }) - } + private static var selector: IntrospectionSelector { + .from(UIViewController.self, selector: { $0.presentationController }) + } } #endif #endif diff --git a/Sources/ViewTypes/SignInWithAppleButton.swift b/Sources/ViewTypes/SignInWithAppleButton.swift index 22db93bd..e83bcf56 100644 --- a/Sources/ViewTypes/SignInWithAppleButton.swift +++ b/Sources/ViewTypes/SignInWithAppleButton.swift @@ -73,19 +73,19 @@ import SwiftUI public struct SignInWithAppleButtonType: IntrospectableViewType {} extension IntrospectableViewType where Self == SignInWithAppleButtonType { - @available( - *, - unavailable, - message: """ - Due to a mysterious bug on Apple's part that may cause a complete - app hang, the unfortunate decision has been made to remove support - for `SignInWithAppleButton` introspection. - - We apologize for this inconvenience. + @available( + *, + unavailable, + message: """ + Due to a mysterious bug on Apple's part that may cause a complete + app hang, the unfortunate decision has been made to remove support + for `SignInWithAppleButton` introspection. - More details can be found at https://github.com/siteline/swiftui-introspect/issues/400 - """ - ) - public static var signInWithAppleButton: Self { .init() } + We apologize for this inconvenience. + + More details can be found at https://github.com/siteline/swiftui-introspect/issues/400 + """ + ) + public static var signInWithAppleButton: Self { .init() } } #endif diff --git a/Sources/ViewTypes/Slider.swift b/Sources/ViewTypes/Slider.swift index d4691c68..49186d22 100644 --- a/Sources/ViewTypes/Slider.swift +++ b/Sources/ViewTypes/Slider.swift @@ -42,32 +42,32 @@ public struct SliderType: IntrospectableViewType {} #if !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == SliderType { - public static var slider: Self { .init() } + public static var slider: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/Stepper.swift b/Sources/ViewTypes/Stepper.swift index 163d459f..fce2fa82 100644 --- a/Sources/ViewTypes/Stepper.swift +++ b/Sources/ViewTypes/Stepper.swift @@ -42,32 +42,32 @@ public struct StepperType: IntrospectableViewType {} #if !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == StepperType { - public static var stepper: Self { .init() } + public static var stepper: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/TabView.swift b/Sources/ViewTypes/TabView.swift index 45691c67..df6f1a4b 100644 --- a/Sources/ViewTypes/TabView.swift +++ b/Sources/ViewTypes/TabView.swift @@ -74,52 +74,52 @@ public struct TabViewType: IntrospectableViewType {} #if !os(visionOS) extension IntrospectableViewType where Self == TabViewType { - public static var tabView: Self { .init() } + public static var tabView: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13, selector: selector) - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v13 = Self(for: .v13, selector: selector) + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - @MainActor - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.tabBarController } - } + @MainActor + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.tabBarController } + } } extension tvOSViewVersion { - public static let v13 = Self(for: .v13, selector: selector) - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v13 = Self(for: .v13, selector: selector) + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - @MainActor - private static var selector: IntrospectionSelector { - .default.withAncestorSelector { $0.tabBarController } - } + @MainActor + private static var selector: IntrospectionSelector { + .default.withAncestorSelector { $0.tabBarController } + } } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/TabViewWithPageStyle.swift b/Sources/ViewTypes/TabViewWithPageStyle.swift index 0fbfacdf..7bba54df 100644 --- a/Sources/ViewTypes/TabViewWithPageStyle.swift +++ b/Sources/ViewTypes/TabViewWithPageStyle.swift @@ -56,45 +56,45 @@ /// } /// ``` public struct TabViewWithPageStyleType: IntrospectableViewType { - public enum Style: Sendable { - case page - } + public enum Style: Sendable { + case page + } } #if !os(macOS) extension IntrospectableViewType where Self == TabViewWithPageStyleType { - public static func tabView(style: Self.Style) -> Self { .init() } + public static func tabView(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: ".tabViewStyle(.page) isn't available on iOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".tabViewStyle(.page) isn't available on iOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - @available(*, unavailable, message: ".tabViewStyle(.page) isn't available on tvOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".tabViewStyle(.page) isn't available on tvOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/Table.swift b/Sources/ViewTypes/Table.swift index 52f6b090..11614f8d 100644 --- a/Sources/ViewTypes/Table.swift +++ b/Sources/ViewTypes/Table.swift @@ -104,43 +104,43 @@ public struct TableType: IntrospectableViewType {} #if !os(tvOS) extension IntrospectableViewType where Self == TableType { - public static var table: Self { .init() } + public static var table: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: "Table isn't available on iOS 13") - public static let v13 = Self(for: .v13) - @available(*, unavailable, message: "Table isn't available on iOS 14") - public static let v14 = Self(for: .v14) - @available(*, unavailable, message: "Table isn't available on iOS 15") - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: "Table isn't available on iOS 13") + public static let v13 = Self(for: .v13) + @available(*, unavailable, message: "Table isn't available on iOS 14") + public static let v14 = Self(for: .v14) + @available(*, unavailable, message: "Table isn't available on iOS 15") + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - @available(*, unavailable, message: "Table isn't available on macOS 10.15") - public static let v10_15 = Self(for: .v10_15) - @available(*, unavailable, message: "Table isn't available on macOS 11") - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: "Table isn't available on macOS 10.15") + public static let v10_15 = Self(for: .v10_15) + @available(*, unavailable, message: "Table isn't available on macOS 11") + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/TextEditor.swift b/Sources/ViewTypes/TextEditor.swift index 88a0cb53..b94211bd 100644 --- a/Sources/ViewTypes/TextEditor.swift +++ b/Sources/ViewTypes/TextEditor.swift @@ -53,40 +53,40 @@ public struct TextEditorType: IntrospectableViewType {} #if !os(tvOS) extension IntrospectableViewType where Self == TextEditorType { - public static var textEditor: Self { .init() } + public static var textEditor: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: "TextEditor isn't available on iOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: "TextEditor isn't available on iOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - @available(*, unavailable, message: "TextEditor isn't available on macOS 10.15") - public static let v10_15 = Self.unavailable() - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: "TextEditor isn't available on macOS 10.15") + public static let v10_15 = Self.unavailable() + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/TextField.swift b/Sources/ViewTypes/TextField.swift index 090e8aea..6c8f3785 100644 --- a/Sources/ViewTypes/TextField.swift +++ b/Sources/ViewTypes/TextField.swift @@ -63,48 +63,48 @@ public struct TextFieldType: IntrospectableViewType {} extension IntrospectableViewType where Self == TextFieldType { - public static var textField: Self { .init() } + public static var textField: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/TextFieldWithVerticalAxis.swift b/Sources/ViewTypes/TextFieldWithVerticalAxis.swift index ae765a1c..b0868b7b 100644 --- a/Sources/ViewTypes/TextFieldWithVerticalAxis.swift +++ b/Sources/ViewTypes/TextFieldWithVerticalAxis.swift @@ -61,13 +61,13 @@ /// } /// ``` public struct TextFieldWithVerticalAxisType: IntrospectableViewType { - public enum Axis: Sendable { - case vertical - } + public enum Axis: Sendable { + case vertical + } } extension IntrospectableViewType where Self == TextFieldWithVerticalAxisType { - public static func textField(axis: Self.Axis) -> Self { .init() } + public static func textField(axis: Self.Axis) -> Self { .init() } } // MARK: SwiftUI.TextField(..., axis: .vertical) - iOS @@ -76,53 +76,53 @@ extension IntrospectableViewType where Self == TextFieldWithVerticalAxisType { public import UIKit extension iOSViewVersion { - @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on iOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on iOS 14") - public static let v14 = Self.unavailable() - @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on iOS 15") - public static let v15 = Self.unavailable() + @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on iOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on iOS 14") + public static let v14 = Self.unavailable() + @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on iOS 15") + public static let v15 = Self.unavailable() - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on tvOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on tvOS 14") - public static let v14 = Self.unavailable() - @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on tvOS 15") - public static let v15 = Self.unavailable() + @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on tvOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on tvOS 14") + public static let v14 = Self.unavailable() + @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on tvOS 15") + public static let v15 = Self.unavailable() - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on macOS 10.15") - public static let v10_15 = Self.unavailable() - @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on macOS 11") - public static let v11 = Self.unavailable() - @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on macOS 12") - public static let v12 = Self.unavailable() + @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on macOS 10.15") + public static let v10_15 = Self.unavailable() + @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on macOS 11") + public static let v11 = Self.unavailable() + @available(*, unavailable, message: "TextField(..., axis: .vertical) isn't available on macOS 12") + public static let v12 = Self.unavailable() - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/Toggle.swift b/Sources/ViewTypes/Toggle.swift index 5875b960..3f8ca529 100644 --- a/Sources/ViewTypes/Toggle.swift +++ b/Sources/ViewTypes/Toggle.swift @@ -42,32 +42,32 @@ public struct ToggleType: IntrospectableViewType {} #if !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == ToggleType { - public static var toggle: Self { .init() } + public static var toggle: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ToggleWithButtonStyle.swift b/Sources/ViewTypes/ToggleWithButtonStyle.swift index aa51f0c1..87175ce4 100644 --- a/Sources/ViewTypes/ToggleWithButtonStyle.swift +++ b/Sources/ViewTypes/ToggleWithButtonStyle.swift @@ -29,29 +29,29 @@ /// /// Not available. public struct ToggleWithButtonStyleType: IntrospectableViewType { - public enum Style: Sendable { - case button - } + public enum Style: Sendable { + case button + } } #if !os(iOS) && !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == ToggleWithButtonStyleType { - public static func toggle(style: Self.Style) -> Self { .init() } + public static func toggle(style: Self.Style) -> Self { .init() } } #if canImport(AppKit) && !targetEnvironment(macCatalyst) public import AppKit extension macOSViewVersion { - @available(*, unavailable, message: ".toggleStyle(.button) isn't available on macOS 10.15") - public static let v10_15 = Self.unavailable() - @available(*, unavailable, message: ".toggleStyle(.button) isn't available on macOS 11") - public static let v11 = Self.unavailable() - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: ".toggleStyle(.button) isn't available on macOS 10.15") + public static let v10_15 = Self.unavailable() + @available(*, unavailable, message: ".toggleStyle(.button) isn't available on macOS 11") + public static let v11 = Self.unavailable() + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ToggleWithCheckboxStyle.swift b/Sources/ViewTypes/ToggleWithCheckboxStyle.swift index 1b16d9d5..9242dc0d 100644 --- a/Sources/ViewTypes/ToggleWithCheckboxStyle.swift +++ b/Sources/ViewTypes/ToggleWithCheckboxStyle.swift @@ -29,27 +29,27 @@ /// /// Not available. public struct ToggleWithCheckboxStyleType: IntrospectableViewType { - public enum Style: Sendable { - case checkbox - } + public enum Style: Sendable { + case checkbox + } } #if !os(iOS) && !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == ToggleWithCheckboxStyleType { - public static func toggle(style: Self.Style) -> Self { .init() } + public static func toggle(style: Self.Style) -> Self { .init() } } #if canImport(AppKit) && !targetEnvironment(macCatalyst) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ToggleWithSwitchStyle.swift b/Sources/ViewTypes/ToggleWithSwitchStyle.swift index 935e327d..b33ea9ca 100644 --- a/Sources/ViewTypes/ToggleWithSwitchStyle.swift +++ b/Sources/ViewTypes/ToggleWithSwitchStyle.swift @@ -41,39 +41,39 @@ /// /// Not available. public struct ToggleWithSwitchStyleType: IntrospectableViewType { - public enum Style: Sendable { - case `switch` - } + public enum Style: Sendable { + case `switch` + } } #if !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == ToggleWithSwitchStyleType { - public static func toggle(style: Self.Style) -> Self { .init() } + public static func toggle(style: Self.Style) -> Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/VideoPlayer.swift b/Sources/ViewTypes/VideoPlayer.swift index c1a4b4d7..d95d3c0d 100644 --- a/Sources/ViewTypes/VideoPlayer.swift +++ b/Sources/ViewTypes/VideoPlayer.swift @@ -60,47 +60,47 @@ public struct VideoPlayerType: IntrospectableViewType {} public import AVKit extension IntrospectableViewType where Self == VideoPlayerType { - public static var videoPlayer: Self { .init() } + public static var videoPlayer: Self { .init() } } #if canImport(UIKit) extension iOSViewVersion { - @available(*, unavailable, message: "VideoPlayer isn't available on iOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: "VideoPlayer isn't available on iOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - @available(*, unavailable, message: "VideoPlayer isn't available on tvOS 13") - public static let v13 = Self.unavailable() - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: "VideoPlayer isn't available on tvOS 13") + public static let v13 = Self.unavailable() + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) extension macOSViewVersion { - @available(*, unavailable, message: "VideoPlayer isn't available on macOS 10.15") - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + @available(*, unavailable, message: "VideoPlayer isn't available on macOS 10.15") + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/View.swift b/Sources/ViewTypes/View.swift index a7014624..c8a66f06 100644 --- a/Sources/ViewTypes/View.swift +++ b/Sources/ViewTypes/View.swift @@ -69,48 +69,48 @@ public struct ViewType: IntrospectableViewType {} // } extension IntrospectableViewType where Self == ViewType { - public static var view: Self { .init() } + public static var view: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15) - public static let v11 = Self(for: .v11) - public static let v12 = Self(for: .v12) - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v26 = Self(for: .v26) + public static let v10_15 = Self(for: .v10_15) + public static let v11 = Self(for: .v11) + public static let v12 = Self(for: .v12) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/ViewController.swift b/Sources/ViewTypes/ViewController.swift index 77e20110..a85bae39 100644 --- a/Sources/ViewTypes/ViewController.swift +++ b/Sources/ViewTypes/ViewController.swift @@ -63,40 +63,40 @@ /// } /// ``` public struct ViewControllerType: IntrospectableViewType { - public var scope: IntrospectionScope { [.receiver, .ancestor] } + public var scope: IntrospectionScope { [.receiver, .ancestor] } } extension IntrospectableViewType where Self == ViewControllerType { - public static var viewController: Self { .init() } + public static var viewController: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - public static let v13 = Self(for: .v13) - public static let v14 = Self(for: .v14) - public static let v15 = Self(for: .v15) - public static let v16 = Self(for: .v16) - public static let v17 = Self(for: .v17) - public static let v18 = Self(for: .v18) - public static let v26 = Self(for: .v26) + public static let v13 = Self(for: .v13) + public static let v14 = Self(for: .v14) + public static let v15 = Self(for: .v15) + public static let v16 = Self(for: .v16) + public static let v17 = Self(for: .v17) + public static let v18 = Self(for: .v18) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - public static let v1 = Self(for: .v1) - public static let v2 = Self(for: .v2) - public static let v26 = Self(for: .v26) + public static let v1 = Self(for: .v1) + public static let v2 = Self(for: .v2) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/WebView.swift b/Sources/ViewTypes/WebView.swift index b2120a81..a3cd87ad 100644 --- a/Sources/ViewTypes/WebView.swift +++ b/Sources/ViewTypes/WebView.swift @@ -70,67 +70,67 @@ public struct WebViewType: IntrospectableViewType {} public import WebKit extension IntrospectableViewType where Self == WebViewType { - public static var webView: Self { .init() } + public static var webView: Self { .init() } } extension iOSViewVersion { - @available(*, unavailable, message: "WebView isn't available on iOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on iOS 14") - public static let v14 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on iOS 15") - public static let v15 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on iOS 16") - public static let v16 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on iOS 17") - public static let v17 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on iOS 18") - public static let v18 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on iOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on iOS 14") + public static let v14 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on iOS 15") + public static let v15 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on iOS 16") + public static let v16 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on iOS 17") + public static let v17 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on iOS 18") + public static let v18 = Self.unavailable() - public static let v26 = Self(for: .v26) + public static let v26 = Self(for: .v26) } extension tvOSViewVersion { - @available(*, unavailable, message: "WebView isn't available on tvOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on tvOS 14") - public static let v14 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on tvOS 15") - public static let v15 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on tvOS 16") - public static let v16 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on tvOS 17") - public static let v17 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on tvOS 18") - public static let v18 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on tvOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on tvOS 14") + public static let v14 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on tvOS 15") + public static let v15 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on tvOS 16") + public static let v16 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on tvOS 17") + public static let v17 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on tvOS 18") + public static let v18 = Self.unavailable() - public static let v26 = Self(for: .v26) + public static let v26 = Self(for: .v26) } extension macOSViewVersion { - @available(*, unavailable, message: "WebView isn't available on macOS 10.15") - public static let v10_15 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on macOS 11") - public static let v11 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on macOS 12") - public static let v12 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on macOS 13") - public static let v13 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on macOS 14") - public static let v14 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on macOS 15") - public static let v15 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on macOS 10.15") + public static let v10_15 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on macOS 11") + public static let v11 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on macOS 12") + public static let v12 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on macOS 13") + public static let v13 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on macOS 14") + public static let v14 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on macOS 15") + public static let v15 = Self.unavailable() - public static let v26 = Self(for: .v26) + public static let v26 = Self(for: .v26) } extension visionOSViewVersion { - @available(*, unavailable, message: "WebView isn't available on visionOS 1") - public static let v1 = Self.unavailable() - @available(*, unavailable, message: "WebView isn't available on visionOS 2") - public static let v2 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on visionOS 1") + public static let v1 = Self.unavailable() + @available(*, unavailable, message: "WebView isn't available on visionOS 2") + public static let v2 = Self.unavailable() - public static let v26 = Self(for: .v26) + public static let v26 = Self(for: .v26) } #endif #endif diff --git a/Sources/ViewTypes/Window.swift b/Sources/ViewTypes/Window.swift index 4e188cd0..a61fbcb1 100644 --- a/Sources/ViewTypes/Window.swift +++ b/Sources/ViewTypes/Window.swift @@ -55,64 +55,64 @@ public struct WindowType: IntrospectableViewType {} extension IntrospectableViewType where Self == WindowType { - public static var window: Self { .init() } + public static var window: Self { .init() } } #if canImport(UIKit) public import UIKit extension iOSViewVersion { - public static let v13 = Self(for: .v13, selector: selector) - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v13 = Self(for: .v13, selector: selector) + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UIView.self, selector: { $0.window }) - } + private static var selector: IntrospectionSelector { + .from(UIView.self, selector: { $0.window }) + } } extension tvOSViewVersion { - public static let v13 = Self(for: .v13, selector: selector) - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v16 = Self(for: .v16, selector: selector) - public static let v17 = Self(for: .v17, selector: selector) - public static let v18 = Self(for: .v18, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v13 = Self(for: .v13, selector: selector) + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v16 = Self(for: .v16, selector: selector) + public static let v17 = Self(for: .v17, selector: selector) + public static let v18 = Self(for: .v18, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UIView.self, selector: { $0.window }) - } + private static var selector: IntrospectionSelector { + .from(UIView.self, selector: { $0.window }) + } } extension visionOSViewVersion { - public static let v1 = Self(for: .v1, selector: selector) - public static let v2 = Self(for: .v2, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v1 = Self(for: .v1, selector: selector) + public static let v2 = Self(for: .v2, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(UIView.self, selector: { $0.window }) - } + private static var selector: IntrospectionSelector { + .from(UIView.self, selector: { $0.window }) + } } #elseif canImport(AppKit) public import AppKit extension macOSViewVersion { - public static let v10_15 = Self(for: .v10_15, selector: selector) - public static let v11 = Self(for: .v11, selector: selector) - public static let v12 = Self(for: .v12, selector: selector) - public static let v13 = Self(for: .v13, selector: selector) - public static let v14 = Self(for: .v14, selector: selector) - public static let v15 = Self(for: .v15, selector: selector) - public static let v26 = Self(for: .v26, selector: selector) + public static let v10_15 = Self(for: .v10_15, selector: selector) + public static let v11 = Self(for: .v11, selector: selector) + public static let v12 = Self(for: .v12, selector: selector) + public static let v13 = Self(for: .v13, selector: selector) + public static let v14 = Self(for: .v14, selector: selector) + public static let v15 = Self(for: .v15, selector: selector) + public static let v26 = Self(for: .v26, selector: selector) - private static var selector: IntrospectionSelector { - .from(NSView.self, selector: { $0.window }) - } + private static var selector: IntrospectionSelector { + .from(NSView.self, selector: { $0.window }) + } } #endif #endif diff --git a/Sources/Weak.swift b/Sources/Weak.swift index f8ec5773..4560aca3 100644 --- a/Sources/Weak.swift +++ b/Sources/Weak.swift @@ -1,14 +1,14 @@ @_spi(Advanced) @propertyWrapper public final class Weak { - private weak var _wrappedValue: T? + private weak var _wrappedValue: T? - public var wrappedValue: T? { - get { _wrappedValue } - set { _wrappedValue = newValue } - } + public var wrappedValue: T? { + get { _wrappedValue } + set { _wrappedValue = newValue } + } - public init(wrappedValue: T? = nil) { - self._wrappedValue = wrappedValue - } + public init(wrappedValue: T? = nil) { + self._wrappedValue = wrappedValue + } } diff --git a/SwiftUIIntrospect.podspec b/SwiftUIIntrospect.podspec index c27ee846..07be0538 100644 --- a/SwiftUIIntrospect.podspec +++ b/SwiftUIIntrospect.podspec @@ -1,20 +1,20 @@ Pod::Spec.new do |spec| - spec.name = 'SwiftUIIntrospect' - spec.version = ENV['LIB_VERSION'] - spec.license = { type: 'MIT' } - spec.homepage = 'https://github.com/siteline/swiftui-introspect' - spec.author = 'David Roman' - spec.summary = 'Introspect underlying UIKit/AppKit components from SwiftUI.' - spec.source = { - git: 'https://github.com/siteline/swiftui-introspect.git', - tag: spec.version - } + spec.name = 'SwiftUIIntrospect' + spec.version = ENV['LIB_VERSION'] + spec.license = { type: 'MIT' } + spec.homepage = 'https://github.com/siteline/swiftui-introspect' + spec.author = 'David Roman' + spec.summary = 'Introspect underlying UIKit/AppKit components from SwiftUI.' + spec.source = { + git: 'https://github.com/siteline/swiftui-introspect.git', + tag: spec.version + } - spec.source_files = 'Sources/**/*.swift' + spec.source_files = 'Sources/**/*.swift' - spec.swift_version = '6.0' - spec.ios.deployment_target = '13.0' - spec.tvos.deployment_target = '13.0' - spec.osx.deployment_target = '10.15' - spec.visionos.deployment_target = '1.0' + spec.swift_version = '6.0' + spec.ios.deployment_target = '13.0' + spec.tvos.deployment_target = '13.0' + spec.osx.deployment_target = '10.15' + spec.visionos.deployment_target = '1.0' end diff --git a/Tests/Tests/PlatformVersionTests.swift b/Tests/Tests/PlatformVersionTests.swift index 6f26ab71..a0665e30 100644 --- a/Tests/Tests/PlatformVersionTests.swift +++ b/Tests/Tests/PlatformVersionTests.swift @@ -3,432 +3,432 @@ import Testing @Suite struct PlatformVersionTests { - @Test func iOS_isCurrent() { - #if os(iOS) - if #available(iOS 26, *) { - #expect(iOSVersion.v26.isCurrent == true) - #expect(iOSVersion.v18.isCurrent == false) - #expect(iOSVersion.v17.isCurrent == false) - #expect(iOSVersion.v16.isCurrent == false) - #expect(iOSVersion.v15.isCurrent == false) - #expect(iOSVersion.v14.isCurrent == false) - #expect(iOSVersion.v13.isCurrent == false) - } else if #available(iOS 18, *) { - #expect(iOSVersion.v18.isCurrent == true) - #expect(iOSVersion.v17.isCurrent == false) - #expect(iOSVersion.v16.isCurrent == false) - #expect(iOSVersion.v15.isCurrent == false) - #expect(iOSVersion.v14.isCurrent == false) - #expect(iOSVersion.v13.isCurrent == false) - } else if #available(iOS 17, *) { - #expect(iOSVersion.v18.isCurrent == false) - #expect(iOSVersion.v17.isCurrent == true) - #expect(iOSVersion.v16.isCurrent == false) - #expect(iOSVersion.v15.isCurrent == false) - #expect(iOSVersion.v14.isCurrent == false) - #expect(iOSVersion.v13.isCurrent == false) - } else if #available(iOS 16, *) { - #expect(iOSVersion.v18.isCurrent == false) - #expect(iOSVersion.v17.isCurrent == false) - #expect(iOSVersion.v16.isCurrent == true) - #expect(iOSVersion.v15.isCurrent == false) - #expect(iOSVersion.v14.isCurrent == false) - #expect(iOSVersion.v13.isCurrent == false) - } else if #available(iOS 15, *) { - #expect(iOSVersion.v18.isCurrent == false) - #expect(iOSVersion.v17.isCurrent == false) - #expect(iOSVersion.v16.isCurrent == false) - #expect(iOSVersion.v15.isCurrent == true) - #expect(iOSVersion.v14.isCurrent == false) - #expect(iOSVersion.v13.isCurrent == false) - } else if #available(iOS 14, *) { - #expect(iOSVersion.v18.isCurrent == false) - #expect(iOSVersion.v17.isCurrent == false) - #expect(iOSVersion.v16.isCurrent == false) - #expect(iOSVersion.v15.isCurrent == false) - #expect(iOSVersion.v14.isCurrent == true) - #expect(iOSVersion.v13.isCurrent == false) - } else if #available(iOS 13, *) { - #expect(iOSVersion.v18.isCurrent == false) - #expect(iOSVersion.v17.isCurrent == false) - #expect(iOSVersion.v16.isCurrent == false) - #expect(iOSVersion.v15.isCurrent == false) - #expect(iOSVersion.v14.isCurrent == false) - #expect(iOSVersion.v13.isCurrent == true) - } - #else - #expect(iOSVersion.v26.isCurrent == false) - #expect(iOSVersion.v18.isCurrent == false) - #expect(iOSVersion.v17.isCurrent == false) - #expect(iOSVersion.v16.isCurrent == false) - #expect(iOSVersion.v15.isCurrent == false) - #expect(iOSVersion.v14.isCurrent == false) - #expect(iOSVersion.v13.isCurrent == false) - #endif - } + @Test func iOS_isCurrent() { + #if os(iOS) + if #available(iOS 26, *) { + #expect(iOSVersion.v26.isCurrent == true) + #expect(iOSVersion.v18.isCurrent == false) + #expect(iOSVersion.v17.isCurrent == false) + #expect(iOSVersion.v16.isCurrent == false) + #expect(iOSVersion.v15.isCurrent == false) + #expect(iOSVersion.v14.isCurrent == false) + #expect(iOSVersion.v13.isCurrent == false) + } else if #available(iOS 18, *) { + #expect(iOSVersion.v18.isCurrent == true) + #expect(iOSVersion.v17.isCurrent == false) + #expect(iOSVersion.v16.isCurrent == false) + #expect(iOSVersion.v15.isCurrent == false) + #expect(iOSVersion.v14.isCurrent == false) + #expect(iOSVersion.v13.isCurrent == false) + } else if #available(iOS 17, *) { + #expect(iOSVersion.v18.isCurrent == false) + #expect(iOSVersion.v17.isCurrent == true) + #expect(iOSVersion.v16.isCurrent == false) + #expect(iOSVersion.v15.isCurrent == false) + #expect(iOSVersion.v14.isCurrent == false) + #expect(iOSVersion.v13.isCurrent == false) + } else if #available(iOS 16, *) { + #expect(iOSVersion.v18.isCurrent == false) + #expect(iOSVersion.v17.isCurrent == false) + #expect(iOSVersion.v16.isCurrent == true) + #expect(iOSVersion.v15.isCurrent == false) + #expect(iOSVersion.v14.isCurrent == false) + #expect(iOSVersion.v13.isCurrent == false) + } else if #available(iOS 15, *) { + #expect(iOSVersion.v18.isCurrent == false) + #expect(iOSVersion.v17.isCurrent == false) + #expect(iOSVersion.v16.isCurrent == false) + #expect(iOSVersion.v15.isCurrent == true) + #expect(iOSVersion.v14.isCurrent == false) + #expect(iOSVersion.v13.isCurrent == false) + } else if #available(iOS 14, *) { + #expect(iOSVersion.v18.isCurrent == false) + #expect(iOSVersion.v17.isCurrent == false) + #expect(iOSVersion.v16.isCurrent == false) + #expect(iOSVersion.v15.isCurrent == false) + #expect(iOSVersion.v14.isCurrent == true) + #expect(iOSVersion.v13.isCurrent == false) + } else if #available(iOS 13, *) { + #expect(iOSVersion.v18.isCurrent == false) + #expect(iOSVersion.v17.isCurrent == false) + #expect(iOSVersion.v16.isCurrent == false) + #expect(iOSVersion.v15.isCurrent == false) + #expect(iOSVersion.v14.isCurrent == false) + #expect(iOSVersion.v13.isCurrent == true) + } + #else + #expect(iOSVersion.v26.isCurrent == false) + #expect(iOSVersion.v18.isCurrent == false) + #expect(iOSVersion.v17.isCurrent == false) + #expect(iOSVersion.v16.isCurrent == false) + #expect(iOSVersion.v15.isCurrent == false) + #expect(iOSVersion.v14.isCurrent == false) + #expect(iOSVersion.v13.isCurrent == false) + #endif + } - @Test func iOS_isCurrentOrPast() { - #if os(iOS) - if #available(iOS 26, *) { - #expect(iOSVersion.v26.isCurrentOrPast == true) - #expect(iOSVersion.v18.isCurrentOrPast == true) - #expect(iOSVersion.v17.isCurrentOrPast == true) - #expect(iOSVersion.v16.isCurrentOrPast == true) - #expect(iOSVersion.v15.isCurrentOrPast == true) - #expect(iOSVersion.v14.isCurrentOrPast == true) - #expect(iOSVersion.v13.isCurrentOrPast == true) - } else if #available(iOS 18, *) { - #expect(iOSVersion.v18.isCurrentOrPast == true) - #expect(iOSVersion.v17.isCurrentOrPast == true) - #expect(iOSVersion.v16.isCurrentOrPast == true) - #expect(iOSVersion.v15.isCurrentOrPast == true) - #expect(iOSVersion.v14.isCurrentOrPast == true) - #expect(iOSVersion.v13.isCurrentOrPast == true) - } else if #available(iOS 17, *) { - #expect(iOSVersion.v18.isCurrentOrPast == false) - #expect(iOSVersion.v17.isCurrentOrPast == true) - #expect(iOSVersion.v16.isCurrentOrPast == true) - #expect(iOSVersion.v15.isCurrentOrPast == true) - #expect(iOSVersion.v14.isCurrentOrPast == true) - #expect(iOSVersion.v13.isCurrentOrPast == true) - } else if #available(iOS 16, *) { - #expect(iOSVersion.v18.isCurrentOrPast == false) - #expect(iOSVersion.v17.isCurrentOrPast == false) - #expect(iOSVersion.v16.isCurrentOrPast == true) - #expect(iOSVersion.v15.isCurrentOrPast == true) - #expect(iOSVersion.v14.isCurrentOrPast == true) - #expect(iOSVersion.v13.isCurrentOrPast == true) - } else if #available(iOS 15, *) { - #expect(iOSVersion.v18.isCurrentOrPast == false) - #expect(iOSVersion.v17.isCurrentOrPast == false) - #expect(iOSVersion.v16.isCurrentOrPast == false) - #expect(iOSVersion.v15.isCurrentOrPast == true) - #expect(iOSVersion.v14.isCurrentOrPast == true) - #expect(iOSVersion.v13.isCurrentOrPast == true) - } else if #available(iOS 14, *) { - #expect(iOSVersion.v18.isCurrentOrPast == false) - #expect(iOSVersion.v17.isCurrentOrPast == false) - #expect(iOSVersion.v16.isCurrentOrPast == false) - #expect(iOSVersion.v15.isCurrentOrPast == false) - #expect(iOSVersion.v14.isCurrentOrPast == true) - #expect(iOSVersion.v13.isCurrentOrPast == true) - } else if #available(iOS 13, *) { - #expect(iOSVersion.v18.isCurrentOrPast == false) - #expect(iOSVersion.v17.isCurrentOrPast == false) - #expect(iOSVersion.v16.isCurrentOrPast == false) - #expect(iOSVersion.v15.isCurrentOrPast == false) - #expect(iOSVersion.v14.isCurrentOrPast == false) - #expect(iOSVersion.v13.isCurrentOrPast == true) - } - #else - #expect(iOSVersion.v26.isCurrentOrPast == false) - #expect(iOSVersion.v18.isCurrentOrPast == false) - #expect(iOSVersion.v17.isCurrentOrPast == false) - #expect(iOSVersion.v16.isCurrentOrPast == false) - #expect(iOSVersion.v15.isCurrentOrPast == false) - #expect(iOSVersion.v14.isCurrentOrPast == false) - #expect(iOSVersion.v13.isCurrentOrPast == false) - #endif - } + @Test func iOS_isCurrentOrPast() { + #if os(iOS) + if #available(iOS 26, *) { + #expect(iOSVersion.v26.isCurrentOrPast == true) + #expect(iOSVersion.v18.isCurrentOrPast == true) + #expect(iOSVersion.v17.isCurrentOrPast == true) + #expect(iOSVersion.v16.isCurrentOrPast == true) + #expect(iOSVersion.v15.isCurrentOrPast == true) + #expect(iOSVersion.v14.isCurrentOrPast == true) + #expect(iOSVersion.v13.isCurrentOrPast == true) + } else if #available(iOS 18, *) { + #expect(iOSVersion.v18.isCurrentOrPast == true) + #expect(iOSVersion.v17.isCurrentOrPast == true) + #expect(iOSVersion.v16.isCurrentOrPast == true) + #expect(iOSVersion.v15.isCurrentOrPast == true) + #expect(iOSVersion.v14.isCurrentOrPast == true) + #expect(iOSVersion.v13.isCurrentOrPast == true) + } else if #available(iOS 17, *) { + #expect(iOSVersion.v18.isCurrentOrPast == false) + #expect(iOSVersion.v17.isCurrentOrPast == true) + #expect(iOSVersion.v16.isCurrentOrPast == true) + #expect(iOSVersion.v15.isCurrentOrPast == true) + #expect(iOSVersion.v14.isCurrentOrPast == true) + #expect(iOSVersion.v13.isCurrentOrPast == true) + } else if #available(iOS 16, *) { + #expect(iOSVersion.v18.isCurrentOrPast == false) + #expect(iOSVersion.v17.isCurrentOrPast == false) + #expect(iOSVersion.v16.isCurrentOrPast == true) + #expect(iOSVersion.v15.isCurrentOrPast == true) + #expect(iOSVersion.v14.isCurrentOrPast == true) + #expect(iOSVersion.v13.isCurrentOrPast == true) + } else if #available(iOS 15, *) { + #expect(iOSVersion.v18.isCurrentOrPast == false) + #expect(iOSVersion.v17.isCurrentOrPast == false) + #expect(iOSVersion.v16.isCurrentOrPast == false) + #expect(iOSVersion.v15.isCurrentOrPast == true) + #expect(iOSVersion.v14.isCurrentOrPast == true) + #expect(iOSVersion.v13.isCurrentOrPast == true) + } else if #available(iOS 14, *) { + #expect(iOSVersion.v18.isCurrentOrPast == false) + #expect(iOSVersion.v17.isCurrentOrPast == false) + #expect(iOSVersion.v16.isCurrentOrPast == false) + #expect(iOSVersion.v15.isCurrentOrPast == false) + #expect(iOSVersion.v14.isCurrentOrPast == true) + #expect(iOSVersion.v13.isCurrentOrPast == true) + } else if #available(iOS 13, *) { + #expect(iOSVersion.v18.isCurrentOrPast == false) + #expect(iOSVersion.v17.isCurrentOrPast == false) + #expect(iOSVersion.v16.isCurrentOrPast == false) + #expect(iOSVersion.v15.isCurrentOrPast == false) + #expect(iOSVersion.v14.isCurrentOrPast == false) + #expect(iOSVersion.v13.isCurrentOrPast == true) + } + #else + #expect(iOSVersion.v26.isCurrentOrPast == false) + #expect(iOSVersion.v18.isCurrentOrPast == false) + #expect(iOSVersion.v17.isCurrentOrPast == false) + #expect(iOSVersion.v16.isCurrentOrPast == false) + #expect(iOSVersion.v15.isCurrentOrPast == false) + #expect(iOSVersion.v14.isCurrentOrPast == false) + #expect(iOSVersion.v13.isCurrentOrPast == false) + #endif + } - @Test func macOS_isCurrent() { - #if os(macOS) - if #available(macOS 26, *) { - #expect(macOSVersion.v26.isCurrent == true) - #expect(macOSVersion.v15.isCurrent == false) - #expect(macOSVersion.v14.isCurrent == false) - #expect(macOSVersion.v13.isCurrent == false) - #expect(macOSVersion.v12.isCurrent == false) - #expect(macOSVersion.v11.isCurrent == false) - #expect(macOSVersion.v10_15.isCurrent == false) - } else if #available(macOS 15, *) { - #expect(macOSVersion.v15.isCurrent == true) - #expect(macOSVersion.v14.isCurrent == false) - #expect(macOSVersion.v13.isCurrent == false) - #expect(macOSVersion.v12.isCurrent == false) - #expect(macOSVersion.v11.isCurrent == false) - #expect(macOSVersion.v10_15.isCurrent == false) - } else if #available(macOS 14, *) { - #expect(macOSVersion.v15.isCurrent == false) - #expect(macOSVersion.v14.isCurrent == true) - #expect(macOSVersion.v13.isCurrent == false) - #expect(macOSVersion.v12.isCurrent == false) - #expect(macOSVersion.v11.isCurrent == false) - #expect(macOSVersion.v10_15.isCurrent == false) - } else if #available(macOS 13, *) { - #expect(macOSVersion.v15.isCurrent == false) - #expect(macOSVersion.v14.isCurrent == false) - #expect(macOSVersion.v13.isCurrent == true) - #expect(macOSVersion.v12.isCurrent == false) - #expect(macOSVersion.v11.isCurrent == false) - #expect(macOSVersion.v10_15.isCurrent == false) - } else if #available(macOS 12, *) { - #expect(macOSVersion.v15.isCurrent == false) - #expect(macOSVersion.v14.isCurrent == false) - #expect(macOSVersion.v13.isCurrent == false) - #expect(macOSVersion.v12.isCurrent == true) - #expect(macOSVersion.v11.isCurrent == false) - #expect(macOSVersion.v10_15.isCurrent == false) - } else if #available(macOS 11, *) { - #expect(macOSVersion.v15.isCurrent == false) - #expect(macOSVersion.v14.isCurrent == false) - #expect(macOSVersion.v13.isCurrent == false) - #expect(macOSVersion.v12.isCurrent == false) - #expect(macOSVersion.v11.isCurrent == true) - #expect(macOSVersion.v10_15.isCurrent == false) - } else if #available(macOS 10.15, *) { - #expect(macOSVersion.v15.isCurrent == false) - #expect(macOSVersion.v14.isCurrent == false) - #expect(macOSVersion.v13.isCurrent == false) - #expect(macOSVersion.v12.isCurrent == false) - #expect(macOSVersion.v11.isCurrent == false) - #expect(macOSVersion.v10_15.isCurrent == true) - } - #else - #expect(macOSVersion.v26.isCurrent == false) - #expect(macOSVersion.v15.isCurrent == false) - #expect(macOSVersion.v14.isCurrent == false) - #expect(macOSVersion.v13.isCurrent == false) - #expect(macOSVersion.v12.isCurrent == false) - #expect(macOSVersion.v11.isCurrent == false) - #expect(macOSVersion.v10_15.isCurrent == false) - #endif - } + @Test func macOS_isCurrent() { + #if os(macOS) + if #available(macOS 26, *) { + #expect(macOSVersion.v26.isCurrent == true) + #expect(macOSVersion.v15.isCurrent == false) + #expect(macOSVersion.v14.isCurrent == false) + #expect(macOSVersion.v13.isCurrent == false) + #expect(macOSVersion.v12.isCurrent == false) + #expect(macOSVersion.v11.isCurrent == false) + #expect(macOSVersion.v10_15.isCurrent == false) + } else if #available(macOS 15, *) { + #expect(macOSVersion.v15.isCurrent == true) + #expect(macOSVersion.v14.isCurrent == false) + #expect(macOSVersion.v13.isCurrent == false) + #expect(macOSVersion.v12.isCurrent == false) + #expect(macOSVersion.v11.isCurrent == false) + #expect(macOSVersion.v10_15.isCurrent == false) + } else if #available(macOS 14, *) { + #expect(macOSVersion.v15.isCurrent == false) + #expect(macOSVersion.v14.isCurrent == true) + #expect(macOSVersion.v13.isCurrent == false) + #expect(macOSVersion.v12.isCurrent == false) + #expect(macOSVersion.v11.isCurrent == false) + #expect(macOSVersion.v10_15.isCurrent == false) + } else if #available(macOS 13, *) { + #expect(macOSVersion.v15.isCurrent == false) + #expect(macOSVersion.v14.isCurrent == false) + #expect(macOSVersion.v13.isCurrent == true) + #expect(macOSVersion.v12.isCurrent == false) + #expect(macOSVersion.v11.isCurrent == false) + #expect(macOSVersion.v10_15.isCurrent == false) + } else if #available(macOS 12, *) { + #expect(macOSVersion.v15.isCurrent == false) + #expect(macOSVersion.v14.isCurrent == false) + #expect(macOSVersion.v13.isCurrent == false) + #expect(macOSVersion.v12.isCurrent == true) + #expect(macOSVersion.v11.isCurrent == false) + #expect(macOSVersion.v10_15.isCurrent == false) + } else if #available(macOS 11, *) { + #expect(macOSVersion.v15.isCurrent == false) + #expect(macOSVersion.v14.isCurrent == false) + #expect(macOSVersion.v13.isCurrent == false) + #expect(macOSVersion.v12.isCurrent == false) + #expect(macOSVersion.v11.isCurrent == true) + #expect(macOSVersion.v10_15.isCurrent == false) + } else if #available(macOS 10.15, *) { + #expect(macOSVersion.v15.isCurrent == false) + #expect(macOSVersion.v14.isCurrent == false) + #expect(macOSVersion.v13.isCurrent == false) + #expect(macOSVersion.v12.isCurrent == false) + #expect(macOSVersion.v11.isCurrent == false) + #expect(macOSVersion.v10_15.isCurrent == true) + } + #else + #expect(macOSVersion.v26.isCurrent == false) + #expect(macOSVersion.v15.isCurrent == false) + #expect(macOSVersion.v14.isCurrent == false) + #expect(macOSVersion.v13.isCurrent == false) + #expect(macOSVersion.v12.isCurrent == false) + #expect(macOSVersion.v11.isCurrent == false) + #expect(macOSVersion.v10_15.isCurrent == false) + #endif + } - @Test func macOS_isCurrentOrPast() { - #if os(macOS) - if #available(macOS 26, *) { - #expect(macOSVersion.v26.isCurrentOrPast == true) - #expect(macOSVersion.v15.isCurrentOrPast == true) - #expect(macOSVersion.v14.isCurrentOrPast == true) - #expect(macOSVersion.v13.isCurrentOrPast == true) - #expect(macOSVersion.v12.isCurrentOrPast == true) - #expect(macOSVersion.v11.isCurrentOrPast == true) - #expect(macOSVersion.v10_15.isCurrentOrPast == true) - } else if #available(macOS 15, *) { - #expect(macOSVersion.v15.isCurrentOrPast == true) - #expect(macOSVersion.v14.isCurrentOrPast == true) - #expect(macOSVersion.v13.isCurrentOrPast == true) - #expect(macOSVersion.v12.isCurrentOrPast == true) - #expect(macOSVersion.v11.isCurrentOrPast == true) - #expect(macOSVersion.v10_15.isCurrentOrPast == true) - } else if #available(macOS 14, *) { - #expect(macOSVersion.v15.isCurrentOrPast == false) - #expect(macOSVersion.v14.isCurrentOrPast == true) - #expect(macOSVersion.v13.isCurrentOrPast == true) - #expect(macOSVersion.v12.isCurrentOrPast == true) - #expect(macOSVersion.v11.isCurrentOrPast == true) - #expect(macOSVersion.v10_15.isCurrentOrPast == true) - } else if #available(macOS 13, *) { - #expect(macOSVersion.v15.isCurrentOrPast == false) - #expect(macOSVersion.v14.isCurrentOrPast == false) - #expect(macOSVersion.v13.isCurrentOrPast == true) - #expect(macOSVersion.v12.isCurrentOrPast == true) - #expect(macOSVersion.v11.isCurrentOrPast == true) - #expect(macOSVersion.v10_15.isCurrentOrPast == true) - } else if #available(macOS 12, *) { - #expect(macOSVersion.v15.isCurrentOrPast == false) - #expect(macOSVersion.v14.isCurrentOrPast == false) - #expect(macOSVersion.v13.isCurrentOrPast == false) - #expect(macOSVersion.v12.isCurrentOrPast == true) - #expect(macOSVersion.v11.isCurrentOrPast == true) - #expect(macOSVersion.v10_15.isCurrentOrPast == true) - } else if #available(macOS 11, *) { - #expect(macOSVersion.v15.isCurrentOrPast == false) - #expect(macOSVersion.v14.isCurrentOrPast == false) - #expect(macOSVersion.v13.isCurrentOrPast == false) - #expect(macOSVersion.v12.isCurrentOrPast == false) - #expect(macOSVersion.v11.isCurrentOrPast == true) - #expect(macOSVersion.v10_15.isCurrentOrPast == true) - } else if #available(macOS 10.15, *) { - #expect(macOSVersion.v15.isCurrentOrPast == false) - #expect(macOSVersion.v14.isCurrentOrPast == false) - #expect(macOSVersion.v13.isCurrentOrPast == false) - #expect(macOSVersion.v12.isCurrentOrPast == false) - #expect(macOSVersion.v11.isCurrentOrPast == false) - #expect(macOSVersion.v10_15.isCurrentOrPast == true) - } - #else - #expect(macOSVersion.v26.isCurrentOrPast == false) - #expect(macOSVersion.v15.isCurrentOrPast == false) - #expect(macOSVersion.v14.isCurrentOrPast == false) - #expect(macOSVersion.v13.isCurrentOrPast == false) - #expect(macOSVersion.v12.isCurrentOrPast == false) - #expect(macOSVersion.v11.isCurrentOrPast == false) - #expect(macOSVersion.v10_15.isCurrentOrPast == false) - #endif - } + @Test func macOS_isCurrentOrPast() { + #if os(macOS) + if #available(macOS 26, *) { + #expect(macOSVersion.v26.isCurrentOrPast == true) + #expect(macOSVersion.v15.isCurrentOrPast == true) + #expect(macOSVersion.v14.isCurrentOrPast == true) + #expect(macOSVersion.v13.isCurrentOrPast == true) + #expect(macOSVersion.v12.isCurrentOrPast == true) + #expect(macOSVersion.v11.isCurrentOrPast == true) + #expect(macOSVersion.v10_15.isCurrentOrPast == true) + } else if #available(macOS 15, *) { + #expect(macOSVersion.v15.isCurrentOrPast == true) + #expect(macOSVersion.v14.isCurrentOrPast == true) + #expect(macOSVersion.v13.isCurrentOrPast == true) + #expect(macOSVersion.v12.isCurrentOrPast == true) + #expect(macOSVersion.v11.isCurrentOrPast == true) + #expect(macOSVersion.v10_15.isCurrentOrPast == true) + } else if #available(macOS 14, *) { + #expect(macOSVersion.v15.isCurrentOrPast == false) + #expect(macOSVersion.v14.isCurrentOrPast == true) + #expect(macOSVersion.v13.isCurrentOrPast == true) + #expect(macOSVersion.v12.isCurrentOrPast == true) + #expect(macOSVersion.v11.isCurrentOrPast == true) + #expect(macOSVersion.v10_15.isCurrentOrPast == true) + } else if #available(macOS 13, *) { + #expect(macOSVersion.v15.isCurrentOrPast == false) + #expect(macOSVersion.v14.isCurrentOrPast == false) + #expect(macOSVersion.v13.isCurrentOrPast == true) + #expect(macOSVersion.v12.isCurrentOrPast == true) + #expect(macOSVersion.v11.isCurrentOrPast == true) + #expect(macOSVersion.v10_15.isCurrentOrPast == true) + } else if #available(macOS 12, *) { + #expect(macOSVersion.v15.isCurrentOrPast == false) + #expect(macOSVersion.v14.isCurrentOrPast == false) + #expect(macOSVersion.v13.isCurrentOrPast == false) + #expect(macOSVersion.v12.isCurrentOrPast == true) + #expect(macOSVersion.v11.isCurrentOrPast == true) + #expect(macOSVersion.v10_15.isCurrentOrPast == true) + } else if #available(macOS 11, *) { + #expect(macOSVersion.v15.isCurrentOrPast == false) + #expect(macOSVersion.v14.isCurrentOrPast == false) + #expect(macOSVersion.v13.isCurrentOrPast == false) + #expect(macOSVersion.v12.isCurrentOrPast == false) + #expect(macOSVersion.v11.isCurrentOrPast == true) + #expect(macOSVersion.v10_15.isCurrentOrPast == true) + } else if #available(macOS 10.15, *) { + #expect(macOSVersion.v15.isCurrentOrPast == false) + #expect(macOSVersion.v14.isCurrentOrPast == false) + #expect(macOSVersion.v13.isCurrentOrPast == false) + #expect(macOSVersion.v12.isCurrentOrPast == false) + #expect(macOSVersion.v11.isCurrentOrPast == false) + #expect(macOSVersion.v10_15.isCurrentOrPast == true) + } + #else + #expect(macOSVersion.v26.isCurrentOrPast == false) + #expect(macOSVersion.v15.isCurrentOrPast == false) + #expect(macOSVersion.v14.isCurrentOrPast == false) + #expect(macOSVersion.v13.isCurrentOrPast == false) + #expect(macOSVersion.v12.isCurrentOrPast == false) + #expect(macOSVersion.v11.isCurrentOrPast == false) + #expect(macOSVersion.v10_15.isCurrentOrPast == false) + #endif + } - @Test func tvOS_isCurrent() { - #if os(tvOS) - if #available(tvOS 26, *) { - #expect(tvOSVersion.v26.isCurrent == true) - #expect(tvOSVersion.v18.isCurrent == false) - #expect(tvOSVersion.v17.isCurrent == false) - #expect(tvOSVersion.v16.isCurrent == false) - #expect(tvOSVersion.v15.isCurrent == false) - #expect(tvOSVersion.v14.isCurrent == false) - #expect(tvOSVersion.v13.isCurrent == false) - } else if #available(tvOS 18, *) { - #expect(tvOSVersion.v18.isCurrent == true) - #expect(tvOSVersion.v17.isCurrent == false) - #expect(tvOSVersion.v16.isCurrent == false) - #expect(tvOSVersion.v15.isCurrent == false) - #expect(tvOSVersion.v14.isCurrent == false) - #expect(tvOSVersion.v13.isCurrent == false) - } else if #available(tvOS 17, *) { - #expect(tvOSVersion.v18.isCurrent == false) - #expect(tvOSVersion.v17.isCurrent == true) - #expect(tvOSVersion.v16.isCurrent == false) - #expect(tvOSVersion.v15.isCurrent == false) - #expect(tvOSVersion.v14.isCurrent == false) - #expect(tvOSVersion.v13.isCurrent == false) - } else if #available(tvOS 16, *) { - #expect(tvOSVersion.v18.isCurrent == false) - #expect(tvOSVersion.v17.isCurrent == false) - #expect(tvOSVersion.v17.isCurrent == false) - #expect(tvOSVersion.v16.isCurrent == true) - #expect(tvOSVersion.v15.isCurrent == false) - #expect(tvOSVersion.v14.isCurrent == false) - #expect(tvOSVersion.v13.isCurrent == false) - } else if #available(tvOS 15, *) { - #expect(tvOSVersion.v18.isCurrent == false) - #expect(tvOSVersion.v17.isCurrent == false) - #expect(tvOSVersion.v16.isCurrent == false) - #expect(tvOSVersion.v15.isCurrent == true) - #expect(tvOSVersion.v14.isCurrent == false) - #expect(tvOSVersion.v13.isCurrent == false) - } else if #available(tvOS 14, *) { - #expect(tvOSVersion.v18.isCurrent == false) - #expect(tvOSVersion.v17.isCurrent == false) - #expect(tvOSVersion.v16.isCurrent == false) - #expect(tvOSVersion.v15.isCurrent == false) - #expect(tvOSVersion.v14.isCurrent == true) - #expect(tvOSVersion.v13.isCurrent == false) - } else if #available(tvOS 13, *) { - #expect(tvOSVersion.v18.isCurrent == false) - #expect(tvOSVersion.v17.isCurrent == false) - #expect(tvOSVersion.v16.isCurrent == false) - #expect(tvOSVersion.v15.isCurrent == false) - #expect(tvOSVersion.v14.isCurrent == false) - #expect(tvOSVersion.v13.isCurrent == true) - } - #else - #expect(tvOSVersion.v26.isCurrent == false) - #expect(tvOSVersion.v18.isCurrent == false) - #expect(tvOSVersion.v17.isCurrent == false) - #expect(tvOSVersion.v16.isCurrent == false) - #expect(tvOSVersion.v15.isCurrent == false) - #expect(tvOSVersion.v14.isCurrent == false) - #expect(tvOSVersion.v13.isCurrent == false) - #endif - } + @Test func tvOS_isCurrent() { + #if os(tvOS) + if #available(tvOS 26, *) { + #expect(tvOSVersion.v26.isCurrent == true) + #expect(tvOSVersion.v18.isCurrent == false) + #expect(tvOSVersion.v17.isCurrent == false) + #expect(tvOSVersion.v16.isCurrent == false) + #expect(tvOSVersion.v15.isCurrent == false) + #expect(tvOSVersion.v14.isCurrent == false) + #expect(tvOSVersion.v13.isCurrent == false) + } else if #available(tvOS 18, *) { + #expect(tvOSVersion.v18.isCurrent == true) + #expect(tvOSVersion.v17.isCurrent == false) + #expect(tvOSVersion.v16.isCurrent == false) + #expect(tvOSVersion.v15.isCurrent == false) + #expect(tvOSVersion.v14.isCurrent == false) + #expect(tvOSVersion.v13.isCurrent == false) + } else if #available(tvOS 17, *) { + #expect(tvOSVersion.v18.isCurrent == false) + #expect(tvOSVersion.v17.isCurrent == true) + #expect(tvOSVersion.v16.isCurrent == false) + #expect(tvOSVersion.v15.isCurrent == false) + #expect(tvOSVersion.v14.isCurrent == false) + #expect(tvOSVersion.v13.isCurrent == false) + } else if #available(tvOS 16, *) { + #expect(tvOSVersion.v18.isCurrent == false) + #expect(tvOSVersion.v17.isCurrent == false) + #expect(tvOSVersion.v17.isCurrent == false) + #expect(tvOSVersion.v16.isCurrent == true) + #expect(tvOSVersion.v15.isCurrent == false) + #expect(tvOSVersion.v14.isCurrent == false) + #expect(tvOSVersion.v13.isCurrent == false) + } else if #available(tvOS 15, *) { + #expect(tvOSVersion.v18.isCurrent == false) + #expect(tvOSVersion.v17.isCurrent == false) + #expect(tvOSVersion.v16.isCurrent == false) + #expect(tvOSVersion.v15.isCurrent == true) + #expect(tvOSVersion.v14.isCurrent == false) + #expect(tvOSVersion.v13.isCurrent == false) + } else if #available(tvOS 14, *) { + #expect(tvOSVersion.v18.isCurrent == false) + #expect(tvOSVersion.v17.isCurrent == false) + #expect(tvOSVersion.v16.isCurrent == false) + #expect(tvOSVersion.v15.isCurrent == false) + #expect(tvOSVersion.v14.isCurrent == true) + #expect(tvOSVersion.v13.isCurrent == false) + } else if #available(tvOS 13, *) { + #expect(tvOSVersion.v18.isCurrent == false) + #expect(tvOSVersion.v17.isCurrent == false) + #expect(tvOSVersion.v16.isCurrent == false) + #expect(tvOSVersion.v15.isCurrent == false) + #expect(tvOSVersion.v14.isCurrent == false) + #expect(tvOSVersion.v13.isCurrent == true) + } + #else + #expect(tvOSVersion.v26.isCurrent == false) + #expect(tvOSVersion.v18.isCurrent == false) + #expect(tvOSVersion.v17.isCurrent == false) + #expect(tvOSVersion.v16.isCurrent == false) + #expect(tvOSVersion.v15.isCurrent == false) + #expect(tvOSVersion.v14.isCurrent == false) + #expect(tvOSVersion.v13.isCurrent == false) + #endif + } - @Test func tvOS_isCurrentOrPast() { - #if os(tvOS) - if #available(tvOS 26, *) { - #expect(tvOSVersion.v26.isCurrentOrPast == true) - #expect(tvOSVersion.v18.isCurrentOrPast == true) - #expect(tvOSVersion.v17.isCurrentOrPast == true) - #expect(tvOSVersion.v16.isCurrentOrPast == true) - #expect(tvOSVersion.v15.isCurrentOrPast == true) - #expect(tvOSVersion.v14.isCurrentOrPast == true) - #expect(tvOSVersion.v13.isCurrentOrPast == true) - } else if #available(tvOS 18, *) { - #expect(tvOSVersion.v18.isCurrentOrPast == true) - #expect(tvOSVersion.v17.isCurrentOrPast == true) - #expect(tvOSVersion.v16.isCurrentOrPast == true) - #expect(tvOSVersion.v15.isCurrentOrPast == true) - #expect(tvOSVersion.v14.isCurrentOrPast == true) - #expect(tvOSVersion.v13.isCurrentOrPast == true) - } else if #available(tvOS 17, *) { - #expect(tvOSVersion.v18.isCurrentOrPast == false) - #expect(tvOSVersion.v17.isCurrentOrPast == true) - #expect(tvOSVersion.v16.isCurrentOrPast == true) - #expect(tvOSVersion.v15.isCurrentOrPast == true) - #expect(tvOSVersion.v14.isCurrentOrPast == true) - #expect(tvOSVersion.v13.isCurrentOrPast == true) - } else if #available(tvOS 16, *) { - #expect(tvOSVersion.v18.isCurrentOrPast == false) - #expect(tvOSVersion.v17.isCurrentOrPast == false) - #expect(tvOSVersion.v16.isCurrentOrPast == true) - #expect(tvOSVersion.v15.isCurrentOrPast == true) - #expect(tvOSVersion.v14.isCurrentOrPast == true) - #expect(tvOSVersion.v13.isCurrentOrPast == true) - } else if #available(tvOS 15, *) { - #expect(tvOSVersion.v18.isCurrentOrPast == false) - #expect(tvOSVersion.v17.isCurrentOrPast == false) - #expect(tvOSVersion.v16.isCurrentOrPast == false) - #expect(tvOSVersion.v15.isCurrentOrPast == true) - #expect(tvOSVersion.v14.isCurrentOrPast == true) - #expect(tvOSVersion.v13.isCurrentOrPast == true) - } else if #available(tvOS 14, *) { - #expect(tvOSVersion.v18.isCurrentOrPast == false) - #expect(tvOSVersion.v17.isCurrentOrPast == false) - #expect(tvOSVersion.v16.isCurrentOrPast == false) - #expect(tvOSVersion.v15.isCurrentOrPast == false) - #expect(tvOSVersion.v14.isCurrentOrPast == true) - #expect(tvOSVersion.v13.isCurrentOrPast == true) - } else if #available(tvOS 13, *) { - #expect(tvOSVersion.v18.isCurrentOrPast == false) - #expect(tvOSVersion.v17.isCurrentOrPast == false) - #expect(tvOSVersion.v16.isCurrentOrPast == false) - #expect(tvOSVersion.v15.isCurrentOrPast == false) - #expect(tvOSVersion.v14.isCurrentOrPast == false) - #expect(tvOSVersion.v13.isCurrentOrPast == true) - } - #else - #expect(tvOSVersion.v26.isCurrentOrPast == false) - #expect(tvOSVersion.v18.isCurrentOrPast == false) - #expect(tvOSVersion.v17.isCurrentOrPast == false) - #expect(tvOSVersion.v16.isCurrentOrPast == false) - #expect(tvOSVersion.v15.isCurrentOrPast == false) - #expect(tvOSVersion.v14.isCurrentOrPast == false) - #expect(tvOSVersion.v13.isCurrentOrPast == false) - #endif - } + @Test func tvOS_isCurrentOrPast() { + #if os(tvOS) + if #available(tvOS 26, *) { + #expect(tvOSVersion.v26.isCurrentOrPast == true) + #expect(tvOSVersion.v18.isCurrentOrPast == true) + #expect(tvOSVersion.v17.isCurrentOrPast == true) + #expect(tvOSVersion.v16.isCurrentOrPast == true) + #expect(tvOSVersion.v15.isCurrentOrPast == true) + #expect(tvOSVersion.v14.isCurrentOrPast == true) + #expect(tvOSVersion.v13.isCurrentOrPast == true) + } else if #available(tvOS 18, *) { + #expect(tvOSVersion.v18.isCurrentOrPast == true) + #expect(tvOSVersion.v17.isCurrentOrPast == true) + #expect(tvOSVersion.v16.isCurrentOrPast == true) + #expect(tvOSVersion.v15.isCurrentOrPast == true) + #expect(tvOSVersion.v14.isCurrentOrPast == true) + #expect(tvOSVersion.v13.isCurrentOrPast == true) + } else if #available(tvOS 17, *) { + #expect(tvOSVersion.v18.isCurrentOrPast == false) + #expect(tvOSVersion.v17.isCurrentOrPast == true) + #expect(tvOSVersion.v16.isCurrentOrPast == true) + #expect(tvOSVersion.v15.isCurrentOrPast == true) + #expect(tvOSVersion.v14.isCurrentOrPast == true) + #expect(tvOSVersion.v13.isCurrentOrPast == true) + } else if #available(tvOS 16, *) { + #expect(tvOSVersion.v18.isCurrentOrPast == false) + #expect(tvOSVersion.v17.isCurrentOrPast == false) + #expect(tvOSVersion.v16.isCurrentOrPast == true) + #expect(tvOSVersion.v15.isCurrentOrPast == true) + #expect(tvOSVersion.v14.isCurrentOrPast == true) + #expect(tvOSVersion.v13.isCurrentOrPast == true) + } else if #available(tvOS 15, *) { + #expect(tvOSVersion.v18.isCurrentOrPast == false) + #expect(tvOSVersion.v17.isCurrentOrPast == false) + #expect(tvOSVersion.v16.isCurrentOrPast == false) + #expect(tvOSVersion.v15.isCurrentOrPast == true) + #expect(tvOSVersion.v14.isCurrentOrPast == true) + #expect(tvOSVersion.v13.isCurrentOrPast == true) + } else if #available(tvOS 14, *) { + #expect(tvOSVersion.v18.isCurrentOrPast == false) + #expect(tvOSVersion.v17.isCurrentOrPast == false) + #expect(tvOSVersion.v16.isCurrentOrPast == false) + #expect(tvOSVersion.v15.isCurrentOrPast == false) + #expect(tvOSVersion.v14.isCurrentOrPast == true) + #expect(tvOSVersion.v13.isCurrentOrPast == true) + } else if #available(tvOS 13, *) { + #expect(tvOSVersion.v18.isCurrentOrPast == false) + #expect(tvOSVersion.v17.isCurrentOrPast == false) + #expect(tvOSVersion.v16.isCurrentOrPast == false) + #expect(tvOSVersion.v15.isCurrentOrPast == false) + #expect(tvOSVersion.v14.isCurrentOrPast == false) + #expect(tvOSVersion.v13.isCurrentOrPast == true) + } + #else + #expect(tvOSVersion.v26.isCurrentOrPast == false) + #expect(tvOSVersion.v18.isCurrentOrPast == false) + #expect(tvOSVersion.v17.isCurrentOrPast == false) + #expect(tvOSVersion.v16.isCurrentOrPast == false) + #expect(tvOSVersion.v15.isCurrentOrPast == false) + #expect(tvOSVersion.v14.isCurrentOrPast == false) + #expect(tvOSVersion.v13.isCurrentOrPast == false) + #endif + } - @Test func visionOS_isCurrent() { - #if os(visionOS) - if #available(visionOS 26, *) { - #expect(visionOSVersion.v26.isCurrent == true) - #expect(visionOSVersion.v2.isCurrent == false) - #expect(visionOSVersion.v1.isCurrent == false) - } else if #available(visionOS 2, *) { - #expect(visionOSVersion.v26.isCurrent == false) - #expect(visionOSVersion.v2.isCurrent == true) - #expect(visionOSVersion.v1.isCurrent == false) - } else if #available(visionOS 1, *) { - #expect(visionOSVersion.v26.isCurrent == false) - #expect(visionOSVersion.v2.isCurrent == false) - #expect(visionOSVersion.v1.isCurrent == true) - } - #else - #expect(visionOSVersion.v26.isCurrent == false) - #expect(visionOSVersion.v2.isCurrent == false) - #expect(visionOSVersion.v1.isCurrent == false) - #endif - } + @Test func visionOS_isCurrent() { + #if os(visionOS) + if #available(visionOS 26, *) { + #expect(visionOSVersion.v26.isCurrent == true) + #expect(visionOSVersion.v2.isCurrent == false) + #expect(visionOSVersion.v1.isCurrent == false) + } else if #available(visionOS 2, *) { + #expect(visionOSVersion.v26.isCurrent == false) + #expect(visionOSVersion.v2.isCurrent == true) + #expect(visionOSVersion.v1.isCurrent == false) + } else if #available(visionOS 1, *) { + #expect(visionOSVersion.v26.isCurrent == false) + #expect(visionOSVersion.v2.isCurrent == false) + #expect(visionOSVersion.v1.isCurrent == true) + } + #else + #expect(visionOSVersion.v26.isCurrent == false) + #expect(visionOSVersion.v2.isCurrent == false) + #expect(visionOSVersion.v1.isCurrent == false) + #endif + } - @Test func visionOS_isCurrentOrPast() { - #if os(visionOS) - if #available(visionOS 26, *) { - #expect(visionOSVersion.v26.isCurrentOrPast == true) - #expect(visionOSVersion.v2.isCurrentOrPast == true) - #expect(visionOSVersion.v1.isCurrentOrPast == true) - } else if #available(visionOS 2, *) { - #expect(visionOSVersion.v26.isCurrentOrPast == false) - #expect(visionOSVersion.v2.isCurrentOrPast == true) - #expect(visionOSVersion.v1.isCurrentOrPast == true) - } else if #available(visionOS 1, *) { - #expect(visionOSVersion.v26.isCurrentOrPast == false) - #expect(visionOSVersion.v2.isCurrentOrPast == false) - #expect(visionOSVersion.v1.isCurrentOrPast == true) - } - #else - #expect(visionOSVersion.v26.isCurrentOrPast == false) - #expect(visionOSVersion.v2.isCurrentOrPast == false) - #expect(visionOSVersion.v1.isCurrentOrPast == false) - #endif - } + @Test func visionOS_isCurrentOrPast() { + #if os(visionOS) + if #available(visionOS 26, *) { + #expect(visionOSVersion.v26.isCurrentOrPast == true) + #expect(visionOSVersion.v2.isCurrentOrPast == true) + #expect(visionOSVersion.v1.isCurrentOrPast == true) + } else if #available(visionOS 2, *) { + #expect(visionOSVersion.v26.isCurrentOrPast == false) + #expect(visionOSVersion.v2.isCurrentOrPast == true) + #expect(visionOSVersion.v1.isCurrentOrPast == true) + } else if #available(visionOS 1, *) { + #expect(visionOSVersion.v26.isCurrentOrPast == false) + #expect(visionOSVersion.v2.isCurrentOrPast == false) + #expect(visionOSVersion.v1.isCurrentOrPast == true) + } + #else + #expect(visionOSVersion.v26.isCurrentOrPast == false) + #expect(visionOSVersion.v2.isCurrentOrPast == false) + #expect(visionOSVersion.v1.isCurrentOrPast == false) + #endif + } } diff --git a/Tests/Tests/TestUtils.swift b/Tests/Tests/TestUtils.swift index 0b12f6ea..fa1c1afc 100644 --- a/Tests/Tests/TestUtils.swift +++ b/Tests/Tests/TestUtils.swift @@ -4,238 +4,238 @@ import Testing #if canImport(UIKit) @MainActor enum TestUtils { - #if targetEnvironment(macCatalyst) || os(visionOS) - static let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 480, height: 300)) - #else - static let window = UIWindow(frame: UIScreen.main.bounds) - #endif - - static func present(view: some View, file: StaticString = #file, line: UInt = #line) { - if let window = - UIApplication.shared.connectedScenes.compactMap({ $0 as? UIWindowScene }).first?.windows.first - ?? - UIApplication.shared.windows.first - { - window.rootViewController = UIHostingController(rootView: view) - } else { - window.rootViewController = UIHostingController(rootView: view) - window.makeKeyAndVisible() - window.layoutIfNeeded() - } - } + #if targetEnvironment(macCatalyst) || os(visionOS) + static let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 480, height: 300)) + #else + static let window = UIWindow(frame: UIScreen.main.bounds) + #endif + + static func present(view: some View, file: StaticString = #file, line: UInt = #line) { + if let window = + UIApplication.shared.connectedScenes.compactMap({ $0 as? UIWindowScene }).first?.windows.first + ?? + UIApplication.shared.windows.first + { + window.rootViewController = UIHostingController(rootView: view) + } else { + window.rootViewController = UIHostingController(rootView: view) + window.makeKeyAndVisible() + window.layoutIfNeeded() + } + } } #elseif canImport(AppKit) @MainActor enum TestUtils { - private static let window = NSWindow( - contentRect: NSRect(x: 0, y: 0, width: 480, height: 300), - styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], - backing: .buffered, - defer: true - ) - - static func present(view: some View) { - window.contentView = NSHostingView(rootView: view) - window.makeKeyAndOrderFront(nil) - window.layoutIfNeeded() - } + private static let window = NSWindow( + contentRect: NSRect(x: 0, y: 0, width: 480, height: 300), + styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], + backing: .buffered, + defer: true + ) + + static func present(view: some View) { + window.contentView = NSHostingView(rootView: view) + window.makeKeyAndOrderFront(nil) + window.layoutIfNeeded() + } } #endif @MainActor @discardableResult func introspection( - of type: Entity.Type, - timeout: TimeInterval = 3, - sourceLocation: SourceLocation = #_sourceLocation, - @ViewBuilder view: ( - _ spy1: @escaping (Entity) -> Void - ) -> some View + of type: Entity.Type, + timeout: TimeInterval = 3, + sourceLocation: SourceLocation = #_sourceLocation, + @ViewBuilder view: ( + _ spy1: @escaping (Entity) -> Void + ) -> some View ) async throws -> Entity { - var entity1: Entity? - return try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation1 in - let view = view( - { - confirmation1() - entity1 = $0 - }, - ) - - TestUtils.present(view: view) - - let startInstant = Date() - while - Date().timeIntervalSince(startInstant) < timeout, - entity1 == nil - { - await Task.yield() - } - - return try #require(entity1, sourceLocation: sourceLocation) - } + var entity1: Entity? + return try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation1 in + let view = view( + { + confirmation1() + entity1 = $0 + }, + ) + + TestUtils.present(view: view) + + let startInstant = Date() + while + Date().timeIntervalSince(startInstant) < timeout, + entity1 == nil + { + await Task.yield() + } + + return try #require(entity1, sourceLocation: sourceLocation) + } } @MainActor @discardableResult func introspection( - of type: Entity.Type, - timeout: TimeInterval = 3, - sourceLocation: SourceLocation = #_sourceLocation, - @ViewBuilder view: ( - _ spy1: @escaping (Entity) -> Void, - _ spy2: @escaping (Entity) -> Void - ) -> some View + of type: Entity.Type, + timeout: TimeInterval = 3, + sourceLocation: SourceLocation = #_sourceLocation, + @ViewBuilder view: ( + _ spy1: @escaping (Entity) -> Void, + _ spy2: @escaping (Entity) -> Void + ) -> some View ) async throws -> (Entity, Entity) { - var entity1: Entity? - var entity2: Entity? - return try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation1 in - try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation2 in - let view = view( - { - confirmation1() - entity1 = $0 - }, - { - confirmation2() - entity2 = $0 - }, - ) - - TestUtils.present(view: view) - - let startInstant = Date() - while - Date().timeIntervalSince(startInstant) < timeout, - entity1 == nil || - entity2 == nil - { - await Task.yield() - } - - return try ( - #require(entity1, sourceLocation: sourceLocation), - #require(entity2, sourceLocation: sourceLocation), - ) - } - } + var entity1: Entity? + var entity2: Entity? + return try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation1 in + try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation2 in + let view = view( + { + confirmation1() + entity1 = $0 + }, + { + confirmation2() + entity2 = $0 + }, + ) + + TestUtils.present(view: view) + + let startInstant = Date() + while + Date().timeIntervalSince(startInstant) < timeout, + entity1 == nil || + entity2 == nil + { + await Task.yield() + } + + return try ( + #require(entity1, sourceLocation: sourceLocation), + #require(entity2, sourceLocation: sourceLocation), + ) + } + } } @MainActor @discardableResult func introspection( - of type: Entity.Type, - timeout: TimeInterval = 3, - sourceLocation: SourceLocation = #_sourceLocation, - @ViewBuilder view: ( - _ spy1: @escaping (Entity) -> Void, - _ spy2: @escaping (Entity) -> Void, - _ spy3: @escaping (Entity) -> Void - ) -> some View + of type: Entity.Type, + timeout: TimeInterval = 3, + sourceLocation: SourceLocation = #_sourceLocation, + @ViewBuilder view: ( + _ spy1: @escaping (Entity) -> Void, + _ spy2: @escaping (Entity) -> Void, + _ spy3: @escaping (Entity) -> Void + ) -> some View ) async throws -> (Entity, Entity, Entity) { - var entity1: Entity? - var entity2: Entity? - var entity3: Entity? - return try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation1 in - try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation2 in - try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation3 in - let view = view( - { - confirmation1() - entity1 = $0 - }, - { - confirmation2() - entity2 = $0 - }, - { - confirmation3() - entity3 = $0 - }, - ) - - TestUtils.present(view: view) - - let startInstant = Date() - while - Date().timeIntervalSince(startInstant) < timeout, - entity1 == nil || - entity2 == nil || - entity3 == nil - { - await Task.yield() - } - - return try ( - #require(entity1, sourceLocation: sourceLocation), - #require(entity2, sourceLocation: sourceLocation), - #require(entity3, sourceLocation: sourceLocation), - ) - } - } - } + var entity1: Entity? + var entity2: Entity? + var entity3: Entity? + return try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation1 in + try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation2 in + try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation3 in + let view = view( + { + confirmation1() + entity1 = $0 + }, + { + confirmation2() + entity2 = $0 + }, + { + confirmation3() + entity3 = $0 + }, + ) + + TestUtils.present(view: view) + + let startInstant = Date() + while + Date().timeIntervalSince(startInstant) < timeout, + entity1 == nil || + entity2 == nil || + entity3 == nil + { + await Task.yield() + } + + return try ( + #require(entity1, sourceLocation: sourceLocation), + #require(entity2, sourceLocation: sourceLocation), + #require(entity3, sourceLocation: sourceLocation), + ) + } + } + } } @MainActor @discardableResult func introspection( - of type: Entity.Type, - timeout: TimeInterval = 3, - sourceLocation: SourceLocation = #_sourceLocation, - @ViewBuilder view: ( - _ spy1: @escaping (Entity) -> Void, - _ spy2: @escaping (Entity) -> Void, - _ spy3: @escaping (Entity) -> Void, - _ spy4: @escaping (Entity) -> Void - ) -> some View + of type: Entity.Type, + timeout: TimeInterval = 3, + sourceLocation: SourceLocation = #_sourceLocation, + @ViewBuilder view: ( + _ spy1: @escaping (Entity) -> Void, + _ spy2: @escaping (Entity) -> Void, + _ spy3: @escaping (Entity) -> Void, + _ spy4: @escaping (Entity) -> Void + ) -> some View ) async throws -> (Entity, Entity, Entity, Entity) { - var entity1: Entity? - var entity2: Entity? - var entity3: Entity? - var entity4: Entity? - return try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation1 in - try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation2 in - try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation3 in - try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation4 in - let view = view( - { - confirmation1() - entity1 = $0 - }, - { - confirmation2() - entity2 = $0 - }, - { - confirmation3() - entity3 = $0 - }, - { - confirmation4() - entity4 = $0 - }, - ) - - TestUtils.present(view: view) - - let startInstant = Date() - while - Date().timeIntervalSince(startInstant) < timeout, - entity1 == nil || - entity2 == nil || - entity3 == nil || - entity4 == nil - { - await Task.yield() - } - - return try ( - #require(entity1, sourceLocation: sourceLocation), - #require(entity2, sourceLocation: sourceLocation), - #require(entity3, sourceLocation: sourceLocation), - #require(entity4, sourceLocation: sourceLocation), - ) - } - } - } - } + var entity1: Entity? + var entity2: Entity? + var entity3: Entity? + var entity4: Entity? + return try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation1 in + try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation2 in + try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation3 in + try await confirmation(expectedCount: 1..., sourceLocation: sourceLocation) { confirmation4 in + let view = view( + { + confirmation1() + entity1 = $0 + }, + { + confirmation2() + entity2 = $0 + }, + { + confirmation3() + entity3 = $0 + }, + { + confirmation4() + entity4 = $0 + }, + ) + + TestUtils.present(view: view) + + let startInstant = Date() + while + Date().timeIntervalSince(startInstant) < timeout, + entity1 == nil || + entity2 == nil || + entity3 == nil || + entity4 == nil + { + await Task.yield() + } + + return try ( + #require(entity1, sourceLocation: sourceLocation), + #require(entity2, sourceLocation: sourceLocation), + #require(entity3, sourceLocation: sourceLocation), + #require(entity4, sourceLocation: sourceLocation), + ) + } + } + } + } } diff --git a/Tests/Tests/ViewTypes/ButtonTests.swift b/Tests/Tests/ViewTypes/ButtonTests.swift index 1c15314f..e0cdf60c 100644 --- a/Tests/Tests/ViewTypes/ButtonTests.swift +++ b/Tests/Tests/ViewTypes/ButtonTests.swift @@ -6,40 +6,40 @@ import Testing @MainActor @Suite struct ButtonTests { - #if canImport(AppKit) - typealias PlatformButton = NSButton - #endif + #if canImport(AppKit) + typealias PlatformButton = NSButton + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3, entity4) = try await introspection(of: PlatformButton.self) { spy1, spy2, spy3, spy4 in - VStack { - Button("Button 0", action: {}) - .buttonStyle(.bordered) - #if os(macOS) - .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2, entity3, entity4) = try await introspection(of: PlatformButton.self) { spy1, spy2, spy3, spy4 in + VStack { + Button("Button 0", action: {}) + .buttonStyle(.bordered) + #if os(macOS) + .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - Button("Button 1", action: {}) - .buttonStyle(.borderless) - #if os(macOS) - .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + Button("Button 1", action: {}) + .buttonStyle(.borderless) + #if os(macOS) + .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - Button("Button 2", action: {}) - .buttonStyle(.link) - #if os(macOS) - .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif + Button("Button 2", action: {}) + .buttonStyle(.link) + #if os(macOS) + .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif - Button("Button 3", action: {}) - #if os(macOS) - .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy4) - #endif - } - } - #if canImport(AppKit) - #expect(Set([entity1, entity2, entity3, entity4].map(ObjectIdentifier.init)).count == 4) - #endif - } + Button("Button 3", action: {}) + #if os(macOS) + .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy4) + #endif + } + } + #if canImport(AppKit) + #expect(Set([entity1, entity2, entity3, entity4].map(ObjectIdentifier.init)).count == 4) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/ColorPickerTests.swift b/Tests/Tests/ViewTypes/ColorPickerTests.swift index c2da636c..23ce99f3 100644 --- a/Tests/Tests/ViewTypes/ColorPickerTests.swift +++ b/Tests/Tests/ViewTypes/ColorPickerTests.swift @@ -6,48 +6,48 @@ import Testing @MainActor @Suite struct ColorPickerTests { - #if canImport(UIKit) - typealias PlatformColor = UIColor - typealias PlatformColorPicker = UIColorWell - #elseif canImport(AppKit) - typealias PlatformColor = NSColor - typealias PlatformColorPicker = NSColorWell - #endif + #if canImport(UIKit) + typealias PlatformColor = UIColor + typealias PlatformColorPicker = UIColorWell + #elseif canImport(AppKit) + typealias PlatformColor = NSColor + typealias PlatformColorPicker = NSColorWell + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformColorPicker.self) { spy1, spy2, spy3 in - VStack { - ColorPicker("", selection: .constant(PlatformColor.red.cgColor)) - #if os(iOS) || os(visionOS) - .introspect(.colorPicker, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.colorPicker, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformColorPicker.self) { spy1, spy2, spy3 in + VStack { + ColorPicker("", selection: .constant(PlatformColor.red.cgColor)) + #if os(iOS) || os(visionOS) + .introspect(.colorPicker, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.colorPicker, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - ColorPicker("", selection: .constant(PlatformColor.green.cgColor)) - #if os(iOS) || os(visionOS) - .introspect(.colorPicker, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.colorPicker, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + ColorPicker("", selection: .constant(PlatformColor.green.cgColor)) + #if os(iOS) || os(visionOS) + .introspect(.colorPicker, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.colorPicker, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - ColorPicker("", selection: .constant(PlatformColor.blue.cgColor)) - #if os(iOS) || os(visionOS) - .introspect(.colorPicker, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.colorPicker, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.selectedColor == .red) - #expect(entity2.selectedColor == .green) - #expect(entity3.selectedColor == .blue) - #elseif canImport(AppKit) - #expect(entity1.color == .red) - #expect(entity2.color == .green) - #expect(entity3.color == .blue) - #endif - } + ColorPicker("", selection: .constant(PlatformColor.blue.cgColor)) + #if os(iOS) || os(visionOS) + .introspect(.colorPicker, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.colorPicker, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.selectedColor == .red) + #expect(entity2.selectedColor == .green) + #expect(entity3.selectedColor == .blue) + #elseif canImport(AppKit) + #expect(entity1.color == .red) + #expect(entity2.color == .green) + #expect(entity3.color == .blue) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/DatePickerTests.swift b/Tests/Tests/ViewTypes/DatePickerTests.swift index e6b515a4..7e22f8ac 100644 --- a/Tests/Tests/ViewTypes/DatePickerTests.swift +++ b/Tests/Tests/ViewTypes/DatePickerTests.swift @@ -6,52 +6,52 @@ import Testing @MainActor @Suite struct DatePickerTests { - #if canImport(UIKit) - typealias PlatformDatePicker = UIDatePicker - #elseif canImport(AppKit) - typealias PlatformDatePicker = NSDatePicker - #endif + #if canImport(UIKit) + typealias PlatformDatePicker = UIDatePicker + #elseif canImport(AppKit) + typealias PlatformDatePicker = NSDatePicker + #endif - @Test func introspect() async throws { - let date1 = Date(timeIntervalSince1970: 0) - let date2 = Date(timeIntervalSince1970: 5) - let date3 = Date(timeIntervalSince1970: 10) + @Test func introspect() async throws { + let date1 = Date(timeIntervalSince1970: 0) + let date2 = Date(timeIntervalSince1970: 5) + let date3 = Date(timeIntervalSince1970: 10) - let (entity1, entity2, entity3) = try await introspection(of: PlatformDatePicker.self) { spy1, spy2, spy3 in - VStack { - DatePicker("", selection: .constant(date1)) - #if os(iOS) || os(visionOS) - .introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + let (entity1, entity2, entity3) = try await introspection(of: PlatformDatePicker.self) { spy1, spy2, spy3 in + VStack { + DatePicker("", selection: .constant(date1)) + #if os(iOS) || os(visionOS) + .introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - DatePicker("", selection: .constant(date2)) - #if os(iOS) || os(visionOS) - .introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + DatePicker("", selection: .constant(date2)) + #if os(iOS) || os(visionOS) + .introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - DatePicker("", selection: .constant(date3)) - #if os(iOS) || os(visionOS) - .introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.date == date1) - #expect(entity2.date == date2) - #expect(entity3.date == date3) - #elseif canImport(AppKit) - #expect(entity1.dateValue == date1) - #expect(entity2.dateValue == date2) - #expect(entity3.dateValue == date3) - #endif - } + DatePicker("", selection: .constant(date3)) + #if os(iOS) || os(visionOS) + .introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.date == date1) + #expect(entity2.date == date2) + #expect(entity3.date == date3) + #elseif canImport(AppKit) + #expect(entity1.dateValue == date1) + #expect(entity2.dateValue == date2) + #expect(entity3.dateValue == date3) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/DatePickerWithCompactFieldStyleTests.swift b/Tests/Tests/ViewTypes/DatePickerWithCompactFieldStyleTests.swift index d1a9379a..09ef7e5b 100644 --- a/Tests/Tests/ViewTypes/DatePickerWithCompactFieldStyleTests.swift +++ b/Tests/Tests/ViewTypes/DatePickerWithCompactFieldStyleTests.swift @@ -6,55 +6,55 @@ import Testing @MainActor @Suite struct DatePickerWithCompactStyleTests { - #if canImport(UIKit) - typealias PlatformDatePickerWithCompactStyle = UIDatePicker - #elseif canImport(AppKit) - typealias PlatformDatePickerWithCompactStyle = NSDatePicker - #endif + #if canImport(UIKit) + typealias PlatformDatePickerWithCompactStyle = UIDatePicker + #elseif canImport(AppKit) + typealias PlatformDatePickerWithCompactStyle = NSDatePicker + #endif - func introspect() async throws { - let date1 = Date(timeIntervalSince1970: 0) - let date2 = Date(timeIntervalSince1970: 5) - let date3 = Date(timeIntervalSince1970: 10) + func introspect() async throws { + let date1 = Date(timeIntervalSince1970: 0) + let date2 = Date(timeIntervalSince1970: 5) + let date3 = Date(timeIntervalSince1970: 10) - let (entity1, entity2, entity3) = try await introspection(of: PlatformDatePickerWithCompactStyle.self) { spy1, spy2, spy3 in - VStack { - DatePicker("", selection: .constant(date1)) - .datePickerStyle(.compact) - #if os(iOS) || os(visionOS) - .introspect(.datePicker(style: .compact), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.datePicker(style: .compact), on: .macOS(.v10_15_4, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + let (entity1, entity2, entity3) = try await introspection(of: PlatformDatePickerWithCompactStyle.self) { spy1, spy2, spy3 in + VStack { + DatePicker("", selection: .constant(date1)) + .datePickerStyle(.compact) + #if os(iOS) || os(visionOS) + .introspect(.datePicker(style: .compact), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.datePicker(style: .compact), on: .macOS(.v10_15_4, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - DatePicker("", selection: .constant(date2)) - .datePickerStyle(.compact) - #if os(iOS) || os(visionOS) - .introspect(.datePicker(style: .compact), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.datePicker(style: .compact), on: .macOS(.v10_15_4, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + DatePicker("", selection: .constant(date2)) + .datePickerStyle(.compact) + #if os(iOS) || os(visionOS) + .introspect(.datePicker(style: .compact), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.datePicker(style: .compact), on: .macOS(.v10_15_4, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - DatePicker("", selection: .constant(date3)) - .datePickerStyle(.compact) - #if os(iOS) || os(visionOS) - .introspect(.datePicker(style: .compact), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.datePicker(style: .compact), on: .macOS(.v10_15_4, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.date == date1) - #expect(entity2.date == date2) - #expect(entity3.date == date3) - #elseif canImport(AppKit) - #expect(entity1.dateValue == date1) - #expect(entity2.dateValue == date2) - #expect(entity3.dateValue == date3) - #endif - } + DatePicker("", selection: .constant(date3)) + .datePickerStyle(.compact) + #if os(iOS) || os(visionOS) + .introspect(.datePicker(style: .compact), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.datePicker(style: .compact), on: .macOS(.v10_15_4, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.date == date1) + #expect(entity2.date == date2) + #expect(entity3.date == date3) + #elseif canImport(AppKit) + #expect(entity1.dateValue == date1) + #expect(entity2.dateValue == date2) + #expect(entity3.dateValue == date3) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/DatePickerWithFieldStyleTests.swift b/Tests/Tests/ViewTypes/DatePickerWithFieldStyleTests.swift index 3cf6fff1..845bb16a 100644 --- a/Tests/Tests/ViewTypes/DatePickerWithFieldStyleTests.swift +++ b/Tests/Tests/ViewTypes/DatePickerWithFieldStyleTests.swift @@ -6,43 +6,43 @@ import Testing @MainActor @Suite struct DatePickerWithFieldStyleTests { - #if canImport(AppKit) && !targetEnvironment(macCatalyst) - typealias PlatformDatePickerWithFieldStyle = NSDatePicker - #endif + #if canImport(AppKit) && !targetEnvironment(macCatalyst) + typealias PlatformDatePickerWithFieldStyle = NSDatePicker + #endif - @Test func introspect() async throws { - let date1 = Date(timeIntervalSince1970: 0) - let date2 = Date(timeIntervalSince1970: 5) - let date3 = Date(timeIntervalSince1970: 10) + @Test func introspect() async throws { + let date1 = Date(timeIntervalSince1970: 0) + let date2 = Date(timeIntervalSince1970: 5) + let date3 = Date(timeIntervalSince1970: 10) - let (entity1, entity2, entity3) = try await introspection(of: PlatformDatePickerWithFieldStyle.self) { spy1, spy2, spy3 in - VStack { - DatePicker("", selection: .constant(date1)) - .datePickerStyle(.field) - #if os(macOS) - .introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + let (entity1, entity2, entity3) = try await introspection(of: PlatformDatePickerWithFieldStyle.self) { spy1, spy2, spy3 in + VStack { + DatePicker("", selection: .constant(date1)) + .datePickerStyle(.field) + #if os(macOS) + .introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - DatePicker("", selection: .constant(date2)) - .datePickerStyle(.field) - #if os(macOS) - .introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + DatePicker("", selection: .constant(date2)) + .datePickerStyle(.field) + #if os(macOS) + .introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - DatePicker("", selection: .constant(date3)) - .datePickerStyle(.field) - #if os(macOS) - .introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(AppKit) && !targetEnvironment(macCatalyst) - #expect(entity1.dateValue == date1) - #expect(entity2.dateValue == date2) - #expect(entity3.dateValue == date3) - #endif - } + DatePicker("", selection: .constant(date3)) + .datePickerStyle(.field) + #if os(macOS) + .introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(AppKit) && !targetEnvironment(macCatalyst) + #expect(entity1.dateValue == date1) + #expect(entity2.dateValue == date2) + #expect(entity3.dateValue == date3) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/DatePickerWithGraphicalStyleTests.swift b/Tests/Tests/ViewTypes/DatePickerWithGraphicalStyleTests.swift index 3034bfdc..236944e0 100644 --- a/Tests/Tests/ViewTypes/DatePickerWithGraphicalStyleTests.swift +++ b/Tests/Tests/ViewTypes/DatePickerWithGraphicalStyleTests.swift @@ -6,55 +6,55 @@ import Testing @MainActor @Suite struct DatePickerWithGraphicalStyleTests { - #if canImport(UIKit) - typealias PlatformDatePickerWithGraphicalStyle = UIDatePicker - #elseif canImport(AppKit) - typealias PlatformDatePickerWithGraphicalStyle = NSDatePicker - #endif + #if canImport(UIKit) + typealias PlatformDatePickerWithGraphicalStyle = UIDatePicker + #elseif canImport(AppKit) + typealias PlatformDatePickerWithGraphicalStyle = NSDatePicker + #endif - @Test func introspect() async throws { - let date1 = Date(timeIntervalSince1970: 0) - let date2 = Date(timeIntervalSince1970: 3600 * 24 * 1) - let date3 = Date(timeIntervalSince1970: 3600 * 24 * 2) + @Test func introspect() async throws { + let date1 = Date(timeIntervalSince1970: 0) + let date2 = Date(timeIntervalSince1970: 3600 * 24 * 1) + let date3 = Date(timeIntervalSince1970: 3600 * 24 * 2) - let (entity1, entity2, entity3) = try await introspection(of: PlatformDatePickerWithGraphicalStyle.self) { spy1, spy2, spy3 in - VStack { - DatePicker("", selection: .constant(date1)) - .datePickerStyle(.graphical) - #if os(iOS) || os(visionOS) - .introspect(.datePicker(style: .graphical), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.datePicker(style: .graphical), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + let (entity1, entity2, entity3) = try await introspection(of: PlatformDatePickerWithGraphicalStyle.self) { spy1, spy2, spy3 in + VStack { + DatePicker("", selection: .constant(date1)) + .datePickerStyle(.graphical) + #if os(iOS) || os(visionOS) + .introspect(.datePicker(style: .graphical), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.datePicker(style: .graphical), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - DatePicker("", selection: .constant(date2)) - .datePickerStyle(.graphical) - #if os(iOS) || os(visionOS) - .introspect(.datePicker(style: .graphical), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.datePicker(style: .graphical), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + DatePicker("", selection: .constant(date2)) + .datePickerStyle(.graphical) + #if os(iOS) || os(visionOS) + .introspect(.datePicker(style: .graphical), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.datePicker(style: .graphical), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - DatePicker("", selection: .constant(date3)) - .datePickerStyle(.graphical) - #if os(iOS) || os(visionOS) - .introspect(.datePicker(style: .graphical), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.datePicker(style: .graphical), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.date == date1) - #expect(entity2.date == date2) - #expect(entity3.date == date3) - #elseif canImport(AppKit) - #expect(entity1.dateValue == date1) - #expect(entity2.dateValue == date2) - #expect(entity3.dateValue == date3) - #endif - } + DatePicker("", selection: .constant(date3)) + .datePickerStyle(.graphical) + #if os(iOS) || os(visionOS) + .introspect(.datePicker(style: .graphical), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.datePicker(style: .graphical), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.date == date1) + #expect(entity2.date == date2) + #expect(entity3.date == date3) + #elseif canImport(AppKit) + #expect(entity1.dateValue == date1) + #expect(entity2.dateValue == date2) + #expect(entity3.dateValue == date3) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/DatePickerWithStepperFieldStyleTests.swift b/Tests/Tests/ViewTypes/DatePickerWithStepperFieldStyleTests.swift index e644b2fa..4e8083d2 100644 --- a/Tests/Tests/ViewTypes/DatePickerWithStepperFieldStyleTests.swift +++ b/Tests/Tests/ViewTypes/DatePickerWithStepperFieldStyleTests.swift @@ -5,43 +5,43 @@ import Testing @MainActor @Suite struct DatePickerWithStepperFieldStyleTests { - #if canImport(AppKit) && !targetEnvironment(macCatalyst) - typealias PlatformDatePickerWithStepperFieldStyle = NSDatePicker - #endif + #if canImport(AppKit) && !targetEnvironment(macCatalyst) + typealias PlatformDatePickerWithStepperFieldStyle = NSDatePicker + #endif - @Test func introspect() async throws { - let date1 = Date(timeIntervalSince1970: 0) - let date2 = Date(timeIntervalSince1970: 5) - let date3 = Date(timeIntervalSince1970: 10) + @Test func introspect() async throws { + let date1 = Date(timeIntervalSince1970: 0) + let date2 = Date(timeIntervalSince1970: 5) + let date3 = Date(timeIntervalSince1970: 10) - let (entity1, entity2, entity3) = try await introspection(of: PlatformDatePickerWithStepperFieldStyle.self) { spy1, spy2, spy3 in - VStack { - DatePicker("", selection: .constant(date1)) - .datePickerStyle(.stepperField) - #if os(macOS) - .introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + let (entity1, entity2, entity3) = try await introspection(of: PlatformDatePickerWithStepperFieldStyle.self) { spy1, spy2, spy3 in + VStack { + DatePicker("", selection: .constant(date1)) + .datePickerStyle(.stepperField) + #if os(macOS) + .introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - DatePicker("", selection: .constant(date2)) - .datePickerStyle(.stepperField) - #if os(macOS) - .introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + DatePicker("", selection: .constant(date2)) + .datePickerStyle(.stepperField) + #if os(macOS) + .introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - DatePicker("", selection: .constant(date3)) - .datePickerStyle(.stepperField) - #if os(macOS) - .introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(AppKit) && !targetEnvironment(macCatalyst) - #expect(entity1.dateValue == date1) - #expect(entity2.dateValue == date2) - #expect(entity3.dateValue == date3) - #endif - } + DatePicker("", selection: .constant(date3)) + .datePickerStyle(.stepperField) + #if os(macOS) + .introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(AppKit) && !targetEnvironment(macCatalyst) + #expect(entity1.dateValue == date1) + #expect(entity2.dateValue == date2) + #expect(entity3.dateValue == date3) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/DatePickerWithWheelStyleTests.swift b/Tests/Tests/ViewTypes/DatePickerWithWheelStyleTests.swift index 30c4e524..549350cb 100644 --- a/Tests/Tests/ViewTypes/DatePickerWithWheelStyleTests.swift +++ b/Tests/Tests/ViewTypes/DatePickerWithWheelStyleTests.swift @@ -6,43 +6,43 @@ import Testing @MainActor @Suite struct DatePickerWithWheelStyleTests { - #if canImport(UIKit) - typealias PlatformDatePickerWithWheelStyle = UIDatePicker - #endif + #if canImport(UIKit) + typealias PlatformDatePickerWithWheelStyle = UIDatePicker + #endif - @Test func introspect() async throws { - let date1 = Date(timeIntervalSince1970: 0) - let date2 = Date(timeIntervalSince1970: 5) - let date3 = Date(timeIntervalSince1970: 10) + @Test func introspect() async throws { + let date1 = Date(timeIntervalSince1970: 0) + let date2 = Date(timeIntervalSince1970: 5) + let date3 = Date(timeIntervalSince1970: 10) - let (entity1, entity2, entity3) = try await introspection(of: PlatformDatePickerWithWheelStyle.self) { spy1, spy2, spy3 in - VStack { - DatePicker("", selection: .constant(date1)) - .datePickerStyle(.wheel) - #if os(iOS) || os(visionOS) - .introspect(.datePicker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #endif - .cornerRadius(8) + let (entity1, entity2, entity3) = try await introspection(of: PlatformDatePickerWithWheelStyle.self) { spy1, spy2, spy3 in + VStack { + DatePicker("", selection: .constant(date1)) + .datePickerStyle(.wheel) + #if os(iOS) || os(visionOS) + .introspect(.datePicker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #endif + .cornerRadius(8) - DatePicker("", selection: .constant(date2)) - .datePickerStyle(.wheel) - #if os(iOS) || os(visionOS) - .introspect(.datePicker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #endif - .cornerRadius(8) + DatePicker("", selection: .constant(date2)) + .datePickerStyle(.wheel) + #if os(iOS) || os(visionOS) + .introspect(.datePicker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #endif + .cornerRadius(8) - DatePicker("", selection: .constant(date3)) - .datePickerStyle(.wheel) - #if os(iOS) || os(visionOS) - .introspect(.datePicker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.date == date1) - #expect(entity2.date == date2) - #expect(entity3.date == date3) - #endif - } + DatePicker("", selection: .constant(date3)) + .datePickerStyle(.wheel) + #if os(iOS) || os(visionOS) + .introspect(.datePicker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.date == date1) + #expect(entity2.date == date2) + #expect(entity3.date == date3) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/FormTests.swift b/Tests/Tests/ViewTypes/FormTests.swift index 866b1110..2714a81a 100644 --- a/Tests/Tests/ViewTypes/FormTests.swift +++ b/Tests/Tests/ViewTypes/FormTests.swift @@ -6,33 +6,33 @@ import Testing @MainActor @Suite struct FormTests { - #if canImport(UIKit) - typealias PlatformForm = UIScrollView // covers both UITableView and UICollectionView - #elseif canImport(AppKit) - typealias PlatformForm = NSScrollView - #endif + #if canImport(UIKit) + typealias PlatformForm = UIScrollView // covers both UITableView and UICollectionView + #elseif canImport(AppKit) + typealias PlatformForm = NSScrollView + #endif - @Test func introspect() async throws { - let (entity1, entity2) = try await introspection(of: PlatformForm.self) { spy1, spy2 in - HStack { - Form { - Text("Item 1") - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.form, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) - .introspect(.form, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2) = try await introspection(of: PlatformForm.self) { spy1, spy2 in + HStack { + Form { + Text("Item 1") + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.form, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) + .introspect(.form, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #endif - Form { - Text("Item 1") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.form, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2) - .introspect(.form, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) - #endif - } - } - } - #expect(entity1 !== entity2) - } + Form { + Text("Item 1") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.form, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2) + .introspect(.form, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) + #endif + } + } + } + #expect(entity1 !== entity2) + } } #endif diff --git a/Tests/Tests/ViewTypes/FormWithGroupedStyleTests.swift b/Tests/Tests/ViewTypes/FormWithGroupedStyleTests.swift index 0e3ed041..4131cd87 100644 --- a/Tests/Tests/ViewTypes/FormWithGroupedStyleTests.swift +++ b/Tests/Tests/ViewTypes/FormWithGroupedStyleTests.swift @@ -5,39 +5,39 @@ import Testing @MainActor @Suite struct FormWithGroupedStyleTests { - #if canImport(UIKit) - typealias PlatformFormWithGroupedStyle = UIScrollView // covers both UITableView and UICollectionView - #elseif canImport(AppKit) - typealias PlatformFormWithGroupedStyle = NSScrollView - #endif + #if canImport(UIKit) + typealias PlatformFormWithGroupedStyle = UIScrollView // covers both UITableView and UICollectionView + #elseif canImport(AppKit) + typealias PlatformFormWithGroupedStyle = NSScrollView + #endif - @available(iOS 16, tvOS 16, macOS 13, *) - @Test func introspect() async throws { - let (entity1, entity2) = try await introspection(of: PlatformFormWithGroupedStyle.self) { spy1, spy2 in - HStack { - Form { - Text("Item 1") - } - .formStyle(.grouped) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.form(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - .introspect(.form(style: .grouped), on: .tvOS(.v16, .v17, .v18, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.form(style: .grouped), on: .macOS(.v13, .v14, .v15, .v26), customize: spy1) - #endif + @available(iOS 16, tvOS 16, macOS 13, *) + @Test func introspect() async throws { + let (entity1, entity2) = try await introspection(of: PlatformFormWithGroupedStyle.self) { spy1, spy2 in + HStack { + Form { + Text("Item 1") + } + .formStyle(.grouped) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.form(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + .introspect(.form(style: .grouped), on: .tvOS(.v16, .v17, .v18, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.form(style: .grouped), on: .macOS(.v13, .v14, .v15, .v26), customize: spy1) + #endif - Form { - Text("Item 1") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.form(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) - .introspect(.form(style: .grouped), on: .tvOS(.v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2) - #elseif os(macOS) - .introspect(.form(style: .grouped), on: .macOS(.v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) - #endif - } - .formStyle(.grouped) - } - } - #expect(entity1 !== entity2) - } + Form { + Text("Item 1") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.form(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) + .introspect(.form(style: .grouped), on: .tvOS(.v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2) + #elseif os(macOS) + .introspect(.form(style: .grouped), on: .macOS(.v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) + #endif + } + .formStyle(.grouped) + } + } + #expect(entity1 !== entity2) + } } diff --git a/Tests/Tests/ViewTypes/FullScreenCoverTests.swift b/Tests/Tests/ViewTypes/FullScreenCoverTests.swift index 421271f8..08845413 100644 --- a/Tests/Tests/ViewTypes/FullScreenCoverTests.swift +++ b/Tests/Tests/ViewTypes/FullScreenCoverTests.swift @@ -6,20 +6,20 @@ import Testing @MainActor @Suite struct FullScreenCoverTests { - @Test func introspect() async throws { - try await introspection(of: UIPresentationController.self) { spy in - Text("Root") - .fullScreenCover(isPresented: .constant(true)) { - Text("Content") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect( - .fullScreenCover, - on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), - customize: spy - ) - #endif - } - } - } + @Test func introspect() async throws { + try await introspection(of: UIPresentationController.self) { spy in + Text("Root") + .fullScreenCover(isPresented: .constant(true)) { + Text("Content") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect( + .fullScreenCover, + on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), + customize: spy + ) + #endif + } + } + } } #endif diff --git a/Tests/Tests/ViewTypes/ListCellTests.swift b/Tests/Tests/ViewTypes/ListCellTests.swift index 4ccad641..cadac8f2 100644 --- a/Tests/Tests/ViewTypes/ListCellTests.swift +++ b/Tests/Tests/ViewTypes/ListCellTests.swift @@ -5,40 +5,40 @@ import Testing @MainActor @Suite struct ListCellTests { - #if canImport(UIKit) - typealias PlatformListCell = UIView // covers both UITableViewCell and UICollectionViewCell - #elseif canImport(AppKit) - typealias PlatformListCell = NSTableCellView - #endif + #if canImport(UIKit) + typealias PlatformListCell = UIView // covers both UITableViewCell and UICollectionViewCell + #elseif canImport(AppKit) + typealias PlatformListCell = NSTableCellView + #endif - @Test func introspect() async throws { - try await introspection(of: PlatformListCell.self) { spy in - List { - Text("Item 1") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.listCell, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy) - .introspect(.listCell, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) - #elseif os(macOS) - .introspect(.listCell, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy) - #endif - } - } - } + @Test func introspect() async throws { + try await introspection(of: PlatformListCell.self) { spy in + List { + Text("Item 1") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.listCell, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy) + .introspect(.listCell, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) + #elseif os(macOS) + .introspect(.listCell, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy) + #endif + } + } + } - @Test func introspectMasked() async throws { - try await introspection(of: PlatformListCell.self) { spy in - List { - Text("Item 1") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.listCell, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy) - .introspect(.listCell, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) - #elseif os(macOS) - .introspect(.listCell, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy) - #endif - .clipped() - .clipShape(RoundedRectangle(cornerRadius: 20.0)) - .cornerRadius(2.0) - } - } - } + @Test func introspectMasked() async throws { + try await introspection(of: PlatformListCell.self) { spy in + List { + Text("Item 1") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.listCell, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy) + .introspect(.listCell, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) + #elseif os(macOS) + .introspect(.listCell, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy) + #endif + .clipped() + .clipShape(RoundedRectangle(cornerRadius: 20.0)) + .cornerRadius(2.0) + } + } + } } diff --git a/Tests/Tests/ViewTypes/ListTests.swift b/Tests/Tests/ViewTypes/ListTests.swift index e8cf9b37..10f218a3 100644 --- a/Tests/Tests/ViewTypes/ListTests.swift +++ b/Tests/Tests/ViewTypes/ListTests.swift @@ -5,89 +5,89 @@ import Testing @MainActor @Suite struct ListTests { - #if canImport(UIKit) - typealias PlatformList = UIScrollView // covers both UITableView and UICollectionView - #elseif canImport(AppKit) - typealias PlatformList = NSTableView - #endif + #if canImport(UIKit) + typealias PlatformList = UIScrollView // covers both UITableView and UICollectionView + #elseif canImport(AppKit) + typealias PlatformList = NSTableView + #endif - @Test func introspect() async throws { - let (entity1, entity2) = try await introspection(of: PlatformList.self) { spy1, spy2 in - HStack { - List { - Text("Item 1") - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) - .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2) = try await introspection(of: PlatformList.self) { spy1, spy2 in + HStack { + List { + Text("Item 1") + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) + .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - List { - Text("Item 1") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2) - .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) - #elseif os(macOS) - .introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) - #endif - } - } - } - #expect(entity1 !== entity2) - } + List { + Text("Item 1") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2) + .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) + #elseif os(macOS) + .introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) + #endif + } + } + } + #expect(entity1 !== entity2) + } - #if !os(macOS) - @Test func introspectNested() async throws { - let (entity1, entity2) = try await introspection(of: PlatformList.self) { spy1, spy2 in - List { - Text("Item 1") + #if !os(macOS) + @Test func introspectNested() async throws { + let (entity1, entity2) = try await introspection(of: PlatformList.self) { spy1, spy2 in + List { + Text("Item 1") - List { - Text("Item 1") - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy2) - .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #endif - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) - .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #endif - } - #expect(entity1 !== entity2) - } - #endif + List { + Text("Item 1") + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy2) + .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #endif + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) + .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #endif + } + #expect(entity1 !== entity2) + } + #endif - @Test func introspectMasked() async throws { - let (entity1, entity2) = try await introspection(of: PlatformList.self) { spy1, spy2 in - HStack { - List { - Text("Item 1") - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) - .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .clipped() - .clipShape(RoundedRectangle(cornerRadius: 20.0)) - .cornerRadius(2.0) + @Test func introspectMasked() async throws { + let (entity1, entity2) = try await introspection(of: PlatformList.self) { spy1, spy2 in + HStack { + List { + Text("Item 1") + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) + .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .clipped() + .clipShape(RoundedRectangle(cornerRadius: 20.0)) + .cornerRadius(2.0) - List { - Text("Item 1") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2) - .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) - #elseif os(macOS) - .introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) - #endif - } - } - } - #expect(entity1 !== entity2) - } + List { + Text("Item 1") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2) + .introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) + #elseif os(macOS) + .introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) + #endif + } + } + } + #expect(entity1 !== entity2) + } } diff --git a/Tests/Tests/ViewTypes/ListWithBorderedStyleTests.swift b/Tests/Tests/ViewTypes/ListWithBorderedStyleTests.swift index dd9603d5..b9128281 100644 --- a/Tests/Tests/ViewTypes/ListWithBorderedStyleTests.swift +++ b/Tests/Tests/ViewTypes/ListWithBorderedStyleTests.swift @@ -6,32 +6,32 @@ import Testing @MainActor @Suite struct ListWithBorderedStyleTests { - #if canImport(AppKit) - typealias PlatformListWithBorderedStyle = NSTableView - #endif + #if canImport(AppKit) + typealias PlatformListWithBorderedStyle = NSTableView + #endif - @available(macOS 12, *) - @Test func introspect() async throws { - let (entity1, entity2) = try await introspection(of: PlatformListWithBorderedStyle.self) { spy1, spy2 in - HStack { - List { - Text("Item 1") - } - .listStyle(.bordered) - #if os(macOS) - .introspect(.list(style: .bordered), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @available(macOS 12, *) + @Test func introspect() async throws { + let (entity1, entity2) = try await introspection(of: PlatformListWithBorderedStyle.self) { spy1, spy2 in + HStack { + List { + Text("Item 1") + } + .listStyle(.bordered) + #if os(macOS) + .introspect(.list(style: .bordered), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - List { - Text("Item 1") - #if os(macOS) - .introspect(.list(style: .bordered), on: .macOS(.v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) - #endif - } - .listStyle(.bordered) - } - } - #expect(entity1 !== entity2) - } + List { + Text("Item 1") + #if os(macOS) + .introspect(.list(style: .bordered), on: .macOS(.v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) + #endif + } + .listStyle(.bordered) + } + } + #expect(entity1 !== entity2) + } } #endif diff --git a/Tests/Tests/ViewTypes/ListWithGroupedStyleTests.swift b/Tests/Tests/ViewTypes/ListWithGroupedStyleTests.swift index f7f3ec6b..3a9179df 100644 --- a/Tests/Tests/ViewTypes/ListWithGroupedStyleTests.swift +++ b/Tests/Tests/ViewTypes/ListWithGroupedStyleTests.swift @@ -6,33 +6,33 @@ import Testing @MainActor @Suite struct ListWithGroupedStyleTests { - #if canImport(UIKit) - typealias PlatformListWithGroupedStyle = UIScrollView // covers both UITableView and UICollectionView - #endif + #if canImport(UIKit) + typealias PlatformListWithGroupedStyle = UIScrollView // covers both UITableView and UICollectionView + #endif - @Test func introspect() async throws { - let (entity1, entity2) = try await introspection(of: PlatformListWithGroupedStyle.self) { spy1, spy2 in - HStack { - List { - Text("Item 1") - } - .listStyle(.grouped) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.list(style: .grouped), on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) - .introspect(.list(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2) = try await introspection(of: PlatformListWithGroupedStyle.self) { spy1, spy2 in + HStack { + List { + Text("Item 1") + } + .listStyle(.grouped) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.list(style: .grouped), on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) + .introspect(.list(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #endif - List { - Text("Item 1") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.list(style: .grouped), on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2) - .introspect(.list(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) - #endif - } - .listStyle(.grouped) - } - } - #expect(entity1 !== entity2) - } + List { + Text("Item 1") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.list(style: .grouped), on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2) + .introspect(.list(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) + #endif + } + .listStyle(.grouped) + } + } + #expect(entity1 !== entity2) + } } #endif diff --git a/Tests/Tests/ViewTypes/ListWithInsetGroupedStyleTests.swift b/Tests/Tests/ViewTypes/ListWithInsetGroupedStyleTests.swift index 28fc45ec..7ce34b43 100644 --- a/Tests/Tests/ViewTypes/ListWithInsetGroupedStyleTests.swift +++ b/Tests/Tests/ViewTypes/ListWithInsetGroupedStyleTests.swift @@ -6,33 +6,33 @@ import Testing @MainActor @Suite struct ListWithInsetGroupedStyleTests { - #if canImport(UIKit) - typealias PlatformListWithInsetGroupedStyle = UIScrollView // covers both UITableView and UICollectionView - #endif + #if canImport(UIKit) + typealias PlatformListWithInsetGroupedStyle = UIScrollView // covers both UITableView and UICollectionView + #endif - @Test func introspect() async throws { - let (entity1, entity2) = try await introspection(of: PlatformListWithInsetGroupedStyle.self) { spy1, spy2 in - HStack { - List { - Text("Item 1") - } - .listStyle(.insetGrouped) - #if os(iOS) || os(visionOS) - .introspect(.list(style: .insetGrouped), on: .iOS(.v14, .v15), customize: spy1) - .introspect(.list(style: .insetGrouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2) = try await introspection(of: PlatformListWithInsetGroupedStyle.self) { spy1, spy2 in + HStack { + List { + Text("Item 1") + } + .listStyle(.insetGrouped) + #if os(iOS) || os(visionOS) + .introspect(.list(style: .insetGrouped), on: .iOS(.v14, .v15), customize: spy1) + .introspect(.list(style: .insetGrouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #endif - List { - Text("Item 1") - #if os(iOS) || os(visionOS) - .introspect(.list(style: .insetGrouped), on: .iOS(.v14, .v15), scope: .ancestor, customize: spy2) - .introspect(.list(style: .insetGrouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) - #endif - } - .listStyle(.insetGrouped) - } - } - #expect(entity1 !== entity2) - } + List { + Text("Item 1") + #if os(iOS) || os(visionOS) + .introspect(.list(style: .insetGrouped), on: .iOS(.v14, .v15), scope: .ancestor, customize: spy2) + .introspect(.list(style: .insetGrouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) + #endif + } + .listStyle(.insetGrouped) + } + } + #expect(entity1 !== entity2) + } } #endif diff --git a/Tests/Tests/ViewTypes/ListWithInsetStyleTests.swift b/Tests/Tests/ViewTypes/ListWithInsetStyleTests.swift index 0482416e..baa6c4d2 100644 --- a/Tests/Tests/ViewTypes/ListWithInsetStyleTests.swift +++ b/Tests/Tests/ViewTypes/ListWithInsetStyleTests.swift @@ -6,39 +6,39 @@ import Testing @MainActor @Suite struct ListWithInsetStyleTests { - #if canImport(UIKit) - typealias PlatformListWithInsetStyle = UIScrollView // covers both UITableView and UICollectionView - #elseif canImport(AppKit) - typealias PlatformListWithInsetStyle = NSTableView - #endif + #if canImport(UIKit) + typealias PlatformListWithInsetStyle = UIScrollView // covers both UITableView and UICollectionView + #elseif canImport(AppKit) + typealias PlatformListWithInsetStyle = NSTableView + #endif - @Test func introspect() async throws { - let (entity1, entity2) = try await introspection(of: PlatformListWithInsetStyle.self) { spy1, spy2 in - HStack { - List { - Text("Item 1") - } - .listStyle(.inset) - #if os(iOS) || os(visionOS) - .introspect(.list(style: .inset), on: .iOS(.v14, .v15), customize: spy1) - .introspect(.list(style: .inset), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.list(style: .inset), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2) = try await introspection(of: PlatformListWithInsetStyle.self) { spy1, spy2 in + HStack { + List { + Text("Item 1") + } + .listStyle(.inset) + #if os(iOS) || os(visionOS) + .introspect(.list(style: .inset), on: .iOS(.v14, .v15), customize: spy1) + .introspect(.list(style: .inset), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.list(style: .inset), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - List { - Text("Item 1") - #if os(iOS) || os(visionOS) - .introspect(.list(style: .inset), on: .iOS(.v14, .v15), scope: .ancestor, customize: spy2) - .introspect(.list(style: .inset), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) - #elseif os(macOS) - .introspect(.list(style: .inset), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) - #endif - } - .listStyle(.inset) - } - } - #expect(entity1 !== entity2) - } + List { + Text("Item 1") + #if os(iOS) || os(visionOS) + .introspect(.list(style: .inset), on: .iOS(.v14, .v15), scope: .ancestor, customize: spy2) + .introspect(.list(style: .inset), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) + #elseif os(macOS) + .introspect(.list(style: .inset), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) + #endif + } + .listStyle(.inset) + } + } + #expect(entity1 !== entity2) + } } #endif diff --git a/Tests/Tests/ViewTypes/ListWithPlainStyleTests.swift b/Tests/Tests/ViewTypes/ListWithPlainStyleTests.swift index 5b462575..bed49ff9 100644 --- a/Tests/Tests/ViewTypes/ListWithPlainStyleTests.swift +++ b/Tests/Tests/ViewTypes/ListWithPlainStyleTests.swift @@ -5,38 +5,38 @@ import Testing @MainActor @Suite struct ListWithPlainStyleTests { - #if canImport(UIKit) - typealias PlatformListWithPlainStyle = UIScrollView // covers both UITableView and UICollectionView - #elseif canImport(AppKit) - typealias PlatformListWithPlainStyle = NSTableView - #endif + #if canImport(UIKit) + typealias PlatformListWithPlainStyle = UIScrollView // covers both UITableView and UICollectionView + #elseif canImport(AppKit) + typealias PlatformListWithPlainStyle = NSTableView + #endif - @Test func introspect() async throws { - let (entity1, entity2) = try await introspection(of: PlatformListWithPlainStyle.self) { spy1, spy2 in - HStack { - List { - Text("Item 1") - } - .listStyle(.plain) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.list(style: .plain), on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) - .introspect(.list(style: .plain), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.list(style: .plain), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2) = try await introspection(of: PlatformListWithPlainStyle.self) { spy1, spy2 in + HStack { + List { + Text("Item 1") + } + .listStyle(.plain) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.list(style: .plain), on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) + .introspect(.list(style: .plain), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.list(style: .plain), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - List { - Text("Item 1") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.list(style: .plain), on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2) - .introspect(.list(style: .plain), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) - #elseif os(macOS) - .introspect(.list(style: .plain), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) - #endif - } - .listStyle(.plain) - } - } - #expect(entity1 !== entity2) - } + List { + Text("Item 1") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.list(style: .plain), on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2) + .introspect(.list(style: .plain), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) + #elseif os(macOS) + .introspect(.list(style: .plain), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) + #endif + } + .listStyle(.plain) + } + } + #expect(entity1 !== entity2) + } } diff --git a/Tests/Tests/ViewTypes/ListWithSidebarStyleTests.swift b/Tests/Tests/ViewTypes/ListWithSidebarStyleTests.swift index 754cef04..7706c0ad 100644 --- a/Tests/Tests/ViewTypes/ListWithSidebarStyleTests.swift +++ b/Tests/Tests/ViewTypes/ListWithSidebarStyleTests.swift @@ -6,39 +6,39 @@ import Testing @MainActor @Suite struct ListWithSidebarStyleTests { - #if canImport(UIKit) - typealias PlatformListWithSidebarStyle = UIScrollView // covers both UITableView and UICollectionView - #elseif canImport(AppKit) - typealias PlatformListWithSidebarStyle = NSTableView - #endif + #if canImport(UIKit) + typealias PlatformListWithSidebarStyle = UIScrollView // covers both UITableView and UICollectionView + #elseif canImport(AppKit) + typealias PlatformListWithSidebarStyle = NSTableView + #endif - @Test func introspect() async throws { - let (entity1, entity2) = try await introspection(of: PlatformListWithSidebarStyle.self) { spy1, spy2 in - HStack { - List { - Text("Item 1") - } - .listStyle(.sidebar) - #if os(iOS) || os(visionOS) - .introspect(.list(style: .sidebar), on: .iOS(.v14, .v15), customize: spy1) - .introspect(.list(style: .sidebar), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.list(style: .sidebar), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2) = try await introspection(of: PlatformListWithSidebarStyle.self) { spy1, spy2 in + HStack { + List { + Text("Item 1") + } + .listStyle(.sidebar) + #if os(iOS) || os(visionOS) + .introspect(.list(style: .sidebar), on: .iOS(.v14, .v15), customize: spy1) + .introspect(.list(style: .sidebar), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.list(style: .sidebar), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - List { - Text("Item 1") - #if os(iOS) || os(visionOS) - .introspect(.list(style: .sidebar), on: .iOS(.v14, .v15), scope: .ancestor, customize: spy2) - .introspect(.list(style: .sidebar), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) - #elseif os(macOS) - .introspect(.list(style: .sidebar), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) - #endif - } - .listStyle(.sidebar) - } - } - #expect(entity1 !== entity2) - } + List { + Text("Item 1") + #if os(iOS) || os(visionOS) + .introspect(.list(style: .sidebar), on: .iOS(.v14, .v15), scope: .ancestor, customize: spy2) + .introspect(.list(style: .sidebar), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) + #elseif os(macOS) + .introspect(.list(style: .sidebar), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) + #endif + } + .listStyle(.sidebar) + } + } + #expect(entity1 !== entity2) + } } #endif diff --git a/Tests/Tests/ViewTypes/MapTests.swift b/Tests/Tests/ViewTypes/MapTests.swift index 9958a550..485e1a14 100644 --- a/Tests/Tests/ViewTypes/MapTests.swift +++ b/Tests/Tests/ViewTypes/MapTests.swift @@ -6,38 +6,38 @@ import Testing @MainActor @Suite struct MapTests { - typealias PlatformMap = MKMapView + typealias PlatformMap = MKMapView - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformMap.self) { spy1, spy2, spy3 in - let region = Binding.constant(MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5))) + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformMap.self) { spy1, spy2, spy3 in + let region = Binding.constant(MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5))) - VStack { - Map(coordinateRegion: region) - .introspect( - .map, - on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .macOS(.v11, .v12, .v13, .v14, .v15, .v26), .visionOS(.v1, .v2, .v26), - customize: spy1 - ) + VStack { + Map(coordinateRegion: region) + .introspect( + .map, + on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .macOS(.v11, .v12, .v13, .v14, .v15, .v26), .visionOS(.v1, .v2, .v26), + customize: spy1 + ) - Map(coordinateRegion: region) - .introspect( - .map, - on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .macOS(.v11, .v12, .v13, .v14, .v15, .v26), .visionOS(.v1, .v2, .v26), - customize: spy2 - ) + Map(coordinateRegion: region) + .introspect( + .map, + on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .macOS(.v11, .v12, .v13, .v14, .v15, .v26), .visionOS(.v1, .v2, .v26), + customize: spy2 + ) - Map(coordinateRegion: region) - .introspect( - .map, - on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .macOS(.v11, .v12, .v13, .v14, .v15, .v26), .visionOS(.v1, .v2, .v26), - customize: spy3 - ) - } - } - #expect(entity1 !== entity2) - #expect(entity1 !== entity3) - #expect(entity2 !== entity3) - } + Map(coordinateRegion: region) + .introspect( + .map, + on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .macOS(.v11, .v12, .v13, .v14, .v15, .v26), .visionOS(.v1, .v2, .v26), + customize: spy3 + ) + } + } + #expect(entity1 !== entity2) + #expect(entity1 !== entity3) + #expect(entity2 !== entity3) + } } #endif diff --git a/Tests/Tests/ViewTypes/NavigationSplitViewTests.swift b/Tests/Tests/ViewTypes/NavigationSplitViewTests.swift index 5cbf7cac..baa963d0 100644 --- a/Tests/Tests/ViewTypes/NavigationSplitViewTests.swift +++ b/Tests/Tests/ViewTypes/NavigationSplitViewTests.swift @@ -5,62 +5,62 @@ import Testing @MainActor @Suite struct NavigationSplitViewTests { - #if canImport(UIKit) && (os(iOS) || os(visionOS)) - typealias PlatformNavigationSplitView = UISplitViewController - #elseif canImport(UIKit) && os(tvOS) - typealias PlatformNavigationSplitView = UINavigationController - #elseif canImport(AppKit) - typealias PlatformNavigationSplitView = NSSplitView - #endif + #if canImport(UIKit) && (os(iOS) || os(visionOS)) + typealias PlatformNavigationSplitView = UISplitViewController + #elseif canImport(UIKit) && os(tvOS) + typealias PlatformNavigationSplitView = UINavigationController + #elseif canImport(AppKit) + typealias PlatformNavigationSplitView = NSSplitView + #endif - @available(iOS 16, macOS 13, *) - @available(tvOS, introduced: 16, obsoleted: 18) - @Test func introspect() async throws { - try await introspection(of: PlatformNavigationSplitView.self) { spy in - NavigationSplitView { - ZStack { - Color.red - Text("Root") - } - } detail: { - ZStack { - Color.blue - Text("Detail") - } - } - #if os(iOS) || os(visionOS) - .introspect(.navigationSplitView, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) - #elseif os(tvOS) - .introspect(.navigationSplitView, on: .tvOS(.v16, .v17), customize: spy) - #elseif os(macOS) - .introspect(.navigationSplitView, on: .macOS(.v13, .v14, .v15, .v26), customize: spy) - #endif - } - } + @available(iOS 16, macOS 13, *) + @available(tvOS, introduced: 16, obsoleted: 18) + @Test func introspect() async throws { + try await introspection(of: PlatformNavigationSplitView.self) { spy in + NavigationSplitView { + ZStack { + Color.red + Text("Root") + } + } detail: { + ZStack { + Color.blue + Text("Detail") + } + } + #if os(iOS) || os(visionOS) + .introspect(.navigationSplitView, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) + #elseif os(tvOS) + .introspect(.navigationSplitView, on: .tvOS(.v16, .v17), customize: spy) + #elseif os(macOS) + .introspect(.navigationSplitView, on: .macOS(.v13, .v14, .v15, .v26), customize: spy) + #endif + } + } - @available(iOS 16, macOS 13, *) - @available(tvOS, introduced: 16, obsoleted: 18) - @Test func introspectAsAncestor() async throws { - try await introspection(of: PlatformNavigationSplitView.self) { spy in - // NB: columnVisibility is explicitly set here for ancestor introspection to work, because initially on iPad the sidebar is hidden, so the introspection modifier isn't triggered until the user makes the sidebar appear. This is why ancestor introspection is discouraged for most situations and it's opt-in. - NavigationSplitView(columnVisibility: .constant(.all)) { - ZStack { - Color.red - Text("Sidebar") - #if os(iOS) || os(visionOS) - .introspect(.navigationSplitView, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) - #elseif os(tvOS) - .introspect(.navigationSplitView, on: .tvOS(.v16, .v17), scope: .ancestor, customize: spy) - #elseif os(macOS) - .introspect(.navigationSplitView, on: .macOS(.v13, .v14, .v15, .v26), scope: .ancestor, customize: spy) - #endif - } - } detail: { - ZStack { - Color.blue - Text("Detail") - } - } - } - } + @available(iOS 16, macOS 13, *) + @available(tvOS, introduced: 16, obsoleted: 18) + @Test func introspectAsAncestor() async throws { + try await introspection(of: PlatformNavigationSplitView.self) { spy in + // NB: columnVisibility is explicitly set here for ancestor introspection to work, because initially on iPad the sidebar is hidden, so the introspection modifier isn't triggered until the user makes the sidebar appear. This is why ancestor introspection is discouraged for most situations and it's opt-in. + NavigationSplitView(columnVisibility: .constant(.all)) { + ZStack { + Color.red + Text("Sidebar") + #if os(iOS) || os(visionOS) + .introspect(.navigationSplitView, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) + #elseif os(tvOS) + .introspect(.navigationSplitView, on: .tvOS(.v16, .v17), scope: .ancestor, customize: spy) + #elseif os(macOS) + .introspect(.navigationSplitView, on: .macOS(.v13, .v14, .v15, .v26), scope: .ancestor, customize: spy) + #endif + } + } detail: { + ZStack { + Color.blue + Text("Detail") + } + } + } + } } diff --git a/Tests/Tests/ViewTypes/NavigationStackTests.swift b/Tests/Tests/ViewTypes/NavigationStackTests.swift index 6dba62c9..de35b763 100644 --- a/Tests/Tests/ViewTypes/NavigationStackTests.swift +++ b/Tests/Tests/ViewTypes/NavigationStackTests.swift @@ -6,38 +6,38 @@ import Testing @MainActor @Suite struct NavigationStackTests { - #if canImport(UIKit) - typealias PlatformNavigationStack = UINavigationController - #endif + #if canImport(UIKit) + typealias PlatformNavigationStack = UINavigationController + #endif - @available(iOS 16, tvOS 16, *) - @Test func introspect() async throws { - try await introspection(of: PlatformNavigationStack.self) { spy in - NavigationStack { - ZStack { - Color.red - Text("Something") - } - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.navigationStack, on: .iOS(.v16, .v17, .v18, .v26), .tvOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) - #endif - } - } + @available(iOS 16, tvOS 16, *) + @Test func introspect() async throws { + try await introspection(of: PlatformNavigationStack.self) { spy in + NavigationStack { + ZStack { + Color.red + Text("Something") + } + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.navigationStack, on: .iOS(.v16, .v17, .v18, .v26), .tvOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) + #endif + } + } - @available(iOS 16, tvOS 16, *) - @Test func introspectAsAncestor() async throws { - try await introspection(of: PlatformNavigationStack.self) { spy in - NavigationStack { - ZStack { - Color.red - Text("Something") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.navigationStack, on: .iOS(.v16, .v17, .v18, .v26), .tvOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) - #endif - } - } - } - } + @available(iOS 16, tvOS 16, *) + @Test func introspectAsAncestor() async throws { + try await introspection(of: PlatformNavigationStack.self) { spy in + NavigationStack { + ZStack { + Color.red + Text("Something") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.navigationStack, on: .iOS(.v16, .v17, .v18, .v26), .tvOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) + #endif + } + } + } + } } #endif diff --git a/Tests/Tests/ViewTypes/NavigationViewWithColumnsStyleTests.swift b/Tests/Tests/ViewTypes/NavigationViewWithColumnsStyleTests.swift index 8cb78860..c4ef5412 100644 --- a/Tests/Tests/ViewTypes/NavigationViewWithColumnsStyleTests.swift +++ b/Tests/Tests/ViewTypes/NavigationViewWithColumnsStyleTests.swift @@ -5,55 +5,55 @@ import Testing @MainActor @Suite struct NavigationViewWithColumnsStyleTests { - #if canImport(UIKit) && (os(iOS) || os(visionOS)) - typealias PlatformNavigationViewWithColumnsStyle = UISplitViewController - #elseif canImport(UIKit) && os(tvOS) - typealias PlatformNavigationViewWithColumnsStyle = UINavigationController - #elseif canImport(AppKit) - typealias PlatformNavigationViewWithColumnsStyle = NSSplitView - #endif + #if canImport(UIKit) && (os(iOS) || os(visionOS)) + typealias PlatformNavigationViewWithColumnsStyle = UISplitViewController + #elseif canImport(UIKit) && os(tvOS) + typealias PlatformNavigationViewWithColumnsStyle = UINavigationController + #elseif canImport(AppKit) + typealias PlatformNavigationViewWithColumnsStyle = NSSplitView + #endif - @Test func introspect() async throws { - try await introspection(of: PlatformNavigationViewWithColumnsStyle.self) { spy in - NavigationView { - ZStack { - Color.red - Text("Something") - } - } - .navigationViewStyle(DoubleColumnNavigationViewStyle()) - #if os(iOS) || os(visionOS) - .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) - #elseif os(tvOS) - .introspect(.navigationView(style: .columns), on: .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy) - #elseif os(macOS) - .introspect(.navigationView(style: .columns), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy) - #endif - } - } + @Test func introspect() async throws { + try await introspection(of: PlatformNavigationViewWithColumnsStyle.self) { spy in + NavigationView { + ZStack { + Color.red + Text("Something") + } + } + .navigationViewStyle(DoubleColumnNavigationViewStyle()) + #if os(iOS) || os(visionOS) + .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) + #elseif os(tvOS) + .introspect(.navigationView(style: .columns), on: .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy) + #elseif os(macOS) + .introspect(.navigationView(style: .columns), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy) + #endif + } + } - @Test func introspectAsAncestor() async throws { - try await introspection(of: PlatformNavigationViewWithColumnsStyle.self) { spy in - NavigationView { - ZStack { - Color.red - Text("Something") - #if os(iOS) || os(visionOS) - .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) - #elseif os(tvOS) - .introspect(.navigationView(style: .columns), on: .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy) - #elseif os(macOS) - .introspect(.navigationView(style: .columns), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy) - #endif - } - } - .navigationViewStyle(DoubleColumnNavigationViewStyle()) - #if os(iOS) - // NB: this is necessary for ancestor introspection to work, because initially on iPad the "Customized" text isn't shown as it's hidden in the sidebar. This is why ancestor introspection is discouraged for most situations and it's opt-in. - .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { - $0.preferredDisplayMode = .oneOverSecondary - } - #endif - } - } + @Test func introspectAsAncestor() async throws { + try await introspection(of: PlatformNavigationViewWithColumnsStyle.self) { spy in + NavigationView { + ZStack { + Color.red + Text("Something") + #if os(iOS) || os(visionOS) + .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) + #elseif os(tvOS) + .introspect(.navigationView(style: .columns), on: .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy) + #elseif os(macOS) + .introspect(.navigationView(style: .columns), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy) + #endif + } + } + .navigationViewStyle(DoubleColumnNavigationViewStyle()) + #if os(iOS) + // NB: this is necessary for ancestor introspection to work, because initially on iPad the "Customized" text isn't shown as it's hidden in the sidebar. This is why ancestor introspection is discouraged for most situations and it's opt-in. + .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { + $0.preferredDisplayMode = .oneOverSecondary + } + #endif + } + } } diff --git a/Tests/Tests/ViewTypes/NavigationViewWithStackStyleTests.swift b/Tests/Tests/ViewTypes/NavigationViewWithStackStyleTests.swift index 50a95ca1..674c3d56 100644 --- a/Tests/Tests/ViewTypes/NavigationViewWithStackStyleTests.swift +++ b/Tests/Tests/ViewTypes/NavigationViewWithStackStyleTests.swift @@ -6,38 +6,38 @@ import Testing @MainActor @Suite struct NavigationViewWithStackStyleTests { - #if canImport(UIKit) - typealias PlatformNavigationViewWithStackStyle = UINavigationController - #endif + #if canImport(UIKit) + typealias PlatformNavigationViewWithStackStyle = UINavigationController + #endif - @Test func introspect() async throws { - try await introspection(of: PlatformNavigationViewWithStackStyle.self) { spy in - NavigationView { - ZStack { - Color.red - Text("Something") - } - } - .navigationViewStyle(.stack) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) - #endif - } - } + @Test func introspect() async throws { + try await introspection(of: PlatformNavigationViewWithStackStyle.self) { spy in + NavigationView { + ZStack { + Color.red + Text("Something") + } + } + .navigationViewStyle(.stack) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) + #endif + } + } - @Test func introspectAsAncestor() async throws { - try await introspection(of: PlatformNavigationViewWithStackStyle.self) { spy in - NavigationView { - ZStack { - Color.red - Text("Something") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) - #endif - } - } - .navigationViewStyle(.stack) - } - } + @Test func introspectAsAncestor() async throws { + try await introspection(of: PlatformNavigationViewWithStackStyle.self) { spy in + NavigationView { + ZStack { + Color.red + Text("Something") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) + #endif + } + } + .navigationViewStyle(.stack) + } + } } #endif diff --git a/Tests/Tests/ViewTypes/PageControlTests.swift b/Tests/Tests/ViewTypes/PageControlTests.swift index 848df2ae..c9df6849 100644 --- a/Tests/Tests/ViewTypes/PageControlTests.swift +++ b/Tests/Tests/ViewTypes/PageControlTests.swift @@ -6,21 +6,21 @@ import Testing @MainActor @Suite struct PageControlTests { - #if canImport(UIKit) - typealias PlatformPageControl = UIPageControl - #endif + #if canImport(UIKit) + typealias PlatformPageControl = UIPageControl + #endif - @Test func introspect() async throws { - try await introspection(of: PlatformPageControl.self) { spy in - TabView { - Text("Page 1").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.red) - Text("Page 2").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.blue) - } - .tabViewStyle(.page(indexDisplayMode: .always)) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.pageControl, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) - #endif - } - } + @Test func introspect() async throws { + try await introspection(of: PlatformPageControl.self) { spy in + TabView { + Text("Page 1").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.red) + Text("Page 2").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.blue) + } + .tabViewStyle(.page(indexDisplayMode: .always)) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.pageControl, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) + #endif + } + } } #endif diff --git a/Tests/Tests/ViewTypes/PickerWithMenuStyleTests.swift b/Tests/Tests/ViewTypes/PickerWithMenuStyleTests.swift index a836a04e..2fdc2115 100644 --- a/Tests/Tests/ViewTypes/PickerWithMenuStyleTests.swift +++ b/Tests/Tests/ViewTypes/PickerWithMenuStyleTests.swift @@ -6,48 +6,48 @@ import Testing @MainActor @Suite struct PickerWithMenuStyleTests { - #if canImport(AppKit) && !targetEnvironment(macCatalyst) - typealias PlatformPickerWithMenuStyle = NSPopUpButton - #endif + #if canImport(AppKit) && !targetEnvironment(macCatalyst) + typealias PlatformPickerWithMenuStyle = NSPopUpButton + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformPickerWithMenuStyle.self) { spy1, spy2, spy3 in - VStack { - Picker("Pick", selection: .constant("1")) { - Text("1").tag("1") - } - .pickerStyle(.menu) - #if os(macOS) - .introspect(.picker(style: .menu), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformPickerWithMenuStyle.self) { spy1, spy2, spy3 in + VStack { + Picker("Pick", selection: .constant("1")) { + Text("1").tag("1") + } + .pickerStyle(.menu) + #if os(macOS) + .introspect(.picker(style: .menu), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - Picker("Pick", selection: .constant("1")) { - Text("1").tag("1") - Text("2").tag("2") - } - .pickerStyle(.menu) - #if os(macOS) - .introspect(.picker(style: .menu), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + Picker("Pick", selection: .constant("1")) { + Text("1").tag("1") + Text("2").tag("2") + } + .pickerStyle(.menu) + #if os(macOS) + .introspect(.picker(style: .menu), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - Picker("Pick", selection: .constant("1")) { - Text("1").tag("1") - Text("2").tag("2") - Text("3").tag("3") - } - .pickerStyle(.menu) - #if os(macOS) - .introspect(.picker(style: .menu), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(AppKit) && !targetEnvironment(macCatalyst) - #expect(entity1.numberOfItems == 1) - #expect(entity2.numberOfItems == 2) - #expect(entity3.numberOfItems == 3) - #endif - } + Picker("Pick", selection: .constant("1")) { + Text("1").tag("1") + Text("2").tag("2") + Text("3").tag("3") + } + .pickerStyle(.menu) + #if os(macOS) + .introspect(.picker(style: .menu), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(AppKit) && !targetEnvironment(macCatalyst) + #expect(entity1.numberOfItems == 1) + #expect(entity2.numberOfItems == 2) + #expect(entity3.numberOfItems == 3) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/PickerWithSegmentedStyleTests.swift b/Tests/Tests/ViewTypes/PickerWithSegmentedStyleTests.swift index c30fb140..ffd24a5f 100644 --- a/Tests/Tests/ViewTypes/PickerWithSegmentedStyleTests.swift +++ b/Tests/Tests/ViewTypes/PickerWithSegmentedStyleTests.swift @@ -5,59 +5,59 @@ import Testing @MainActor @Suite struct PickerWithSegmentedStyleTests { - #if canImport(UIKit) - typealias PlatformPickerWithSegmentedStyle = UISegmentedControl - #elseif canImport(AppKit) - typealias PlatformPickerWithSegmentedStyle = NSSegmentedControl - #endif + #if canImport(UIKit) + typealias PlatformPickerWithSegmentedStyle = UISegmentedControl + #elseif canImport(AppKit) + typealias PlatformPickerWithSegmentedStyle = NSSegmentedControl + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformPickerWithSegmentedStyle.self) { spy1, spy2, spy3 in - VStack { - Picker("Pick", selection: .constant("1")) { - Text("1").tag("1") - } - .pickerStyle(.segmented) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.picker(style: .segmented), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.picker(style: .segmented), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformPickerWithSegmentedStyle.self) { spy1, spy2, spy3 in + VStack { + Picker("Pick", selection: .constant("1")) { + Text("1").tag("1") + } + .pickerStyle(.segmented) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.picker(style: .segmented), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.picker(style: .segmented), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - Picker("Pick", selection: .constant("1")) { - Text("1").tag("1") - Text("2").tag("2") - } - .pickerStyle(.segmented) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.picker(style: .segmented), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.picker(style: .segmented), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + Picker("Pick", selection: .constant("1")) { + Text("1").tag("1") + Text("2").tag("2") + } + .pickerStyle(.segmented) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.picker(style: .segmented), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.picker(style: .segmented), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - Picker("Pick", selection: .constant("1")) { - Text("1").tag("1") - Text("2").tag("2") - Text("3").tag("3") - } - .pickerStyle(.segmented) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.picker(style: .segmented), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.picker(style: .segmented), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.numberOfSegments == 1) - #expect(entity2.numberOfSegments == 2) - #expect(entity3.numberOfSegments == 3) - #elseif canImport(AppKit) - #expect(entity1.segmentCount == 1) - #expect(entity2.segmentCount == 2) - #expect(entity3.segmentCount == 3) - #endif - } + Picker("Pick", selection: .constant("1")) { + Text("1").tag("1") + Text("2").tag("2") + Text("3").tag("3") + } + .pickerStyle(.segmented) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.picker(style: .segmented), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.picker(style: .segmented), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.numberOfSegments == 1) + #expect(entity2.numberOfSegments == 2) + #expect(entity3.numberOfSegments == 3) + #elseif canImport(AppKit) + #expect(entity1.segmentCount == 1) + #expect(entity2.segmentCount == 2) + #expect(entity3.segmentCount == 3) + #endif + } } diff --git a/Tests/Tests/ViewTypes/PickerWithWheelStyleTests.swift b/Tests/Tests/ViewTypes/PickerWithWheelStyleTests.swift index de1bfaa6..92726a9f 100644 --- a/Tests/Tests/ViewTypes/PickerWithWheelStyleTests.swift +++ b/Tests/Tests/ViewTypes/PickerWithWheelStyleTests.swift @@ -6,48 +6,48 @@ import Testing @MainActor @Suite struct PickerWithWheelStyleTests { - #if canImport(UIKit) - typealias PlatformPickerWithWheelStyle = UIPickerView - #endif + #if canImport(UIKit) + typealias PlatformPickerWithWheelStyle = UIPickerView + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformPickerWithWheelStyle.self) { spy1, spy2, spy3 in - VStack { - Picker("Pick", selection: .constant("1")) { - Text("1").tag("1") - } - .pickerStyle(.wheel) - #if os(iOS) || os(visionOS) - .introspect(.picker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #endif - .cornerRadius(8) + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformPickerWithWheelStyle.self) { spy1, spy2, spy3 in + VStack { + Picker("Pick", selection: .constant("1")) { + Text("1").tag("1") + } + .pickerStyle(.wheel) + #if os(iOS) || os(visionOS) + .introspect(.picker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #endif + .cornerRadius(8) - Picker("Pick", selection: .constant("1")) { - Text("1").tag("1") - Text("2").tag("2") - } - .pickerStyle(.wheel) - #if os(iOS) || os(visionOS) - .introspect(.picker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #endif - .cornerRadius(8) + Picker("Pick", selection: .constant("1")) { + Text("1").tag("1") + Text("2").tag("2") + } + .pickerStyle(.wheel) + #if os(iOS) || os(visionOS) + .introspect(.picker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #endif + .cornerRadius(8) - Picker("Pick", selection: .constant("1")) { - Text("1").tag("1") - Text("2").tag("2") - Text("3").tag("3") - } - .pickerStyle(.wheel) - #if os(iOS) || os(visionOS) - .introspect(.picker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.numberOfRows(inComponent: 0) == 1) - #expect(entity2.numberOfRows(inComponent: 0) == 2) - #expect(entity3.numberOfRows(inComponent: 0) == 3) - #endif - } + Picker("Pick", selection: .constant("1")) { + Text("1").tag("1") + Text("2").tag("2") + Text("3").tag("3") + } + .pickerStyle(.wheel) + #if os(iOS) || os(visionOS) + .introspect(.picker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.numberOfRows(inComponent: 0) == 1) + #expect(entity2.numberOfRows(inComponent: 0) == 2) + #expect(entity3.numberOfRows(inComponent: 0) == 3) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/PopoverTests.swift b/Tests/Tests/ViewTypes/PopoverTests.swift index d8af3704..b9e90d0c 100644 --- a/Tests/Tests/ViewTypes/PopoverTests.swift +++ b/Tests/Tests/ViewTypes/PopoverTests.swift @@ -6,18 +6,18 @@ import Testing @MainActor @Suite struct PopoverTests { - @Test func introspect() async throws { - try await introspection(of: UIPopoverPresentationController.self) { spy in - Text("Root") - .popover(isPresented: .constant(true)) { - Text("Popover") - .introspect( - .popover, - on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), - customize: spy - ) - } - } - } + @Test func introspect() async throws { + try await introspection(of: UIPopoverPresentationController.self) { spy in + Text("Root") + .popover(isPresented: .constant(true)) { + Text("Popover") + .introspect( + .popover, + on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), + customize: spy + ) + } + } + } } #endif diff --git a/Tests/Tests/ViewTypes/ProgressViewWithCircularStyleTests.swift b/Tests/Tests/ViewTypes/ProgressViewWithCircularStyleTests.swift index 571c89e4..d551844c 100644 --- a/Tests/Tests/ViewTypes/ProgressViewWithCircularStyleTests.swift +++ b/Tests/Tests/ViewTypes/ProgressViewWithCircularStyleTests.swift @@ -5,44 +5,44 @@ import Testing @MainActor @Suite struct ProgressViewWithCircularStyleTests { - #if canImport(UIKit) - typealias PlatformProgressViewWithCircularStyle = UIActivityIndicatorView - #elseif canImport(AppKit) - typealias PlatformProgressViewWithCircularStyle = NSProgressIndicator - #endif + #if canImport(UIKit) + typealias PlatformProgressViewWithCircularStyle = UIActivityIndicatorView + #elseif canImport(AppKit) + typealias PlatformProgressViewWithCircularStyle = NSProgressIndicator + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformProgressViewWithCircularStyle.self) { spy1, spy2, spy3 in - VStack { - ProgressView(value: 0.25) - .progressViewStyle(.circular) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.progressView(style: .circular), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.progressView(style: .circular), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformProgressViewWithCircularStyle.self) { spy1, spy2, spy3 in + VStack { + ProgressView(value: 0.25) + .progressViewStyle(.circular) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.progressView(style: .circular), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.progressView(style: .circular), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - ProgressView(value: 0.5) - .progressViewStyle(.circular) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.progressView(style: .circular), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.progressView(style: .circular), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + ProgressView(value: 0.5) + .progressViewStyle(.circular) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.progressView(style: .circular), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.progressView(style: .circular), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - ProgressView(value: 0.75) - .progressViewStyle(.circular) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.progressView(style: .circular), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.progressView(style: .circular), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(AppKit) && !targetEnvironment(macCatalyst) - #expect(entity1.doubleValue == 0.25) - #expect(entity2.doubleValue == 0.5) - #expect(entity3.doubleValue == 0.75) - #endif - } + ProgressView(value: 0.75) + .progressViewStyle(.circular) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.progressView(style: .circular), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.progressView(style: .circular), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(AppKit) && !targetEnvironment(macCatalyst) + #expect(entity1.doubleValue == 0.25) + #expect(entity2.doubleValue == 0.5) + #expect(entity3.doubleValue == 0.75) + #endif + } } diff --git a/Tests/Tests/ViewTypes/ProgressViewWithLinearStyleTests.swift b/Tests/Tests/ViewTypes/ProgressViewWithLinearStyleTests.swift index ce69a5e0..5cb228c7 100644 --- a/Tests/Tests/ViewTypes/ProgressViewWithLinearStyleTests.swift +++ b/Tests/Tests/ViewTypes/ProgressViewWithLinearStyleTests.swift @@ -5,48 +5,48 @@ import Testing @MainActor @Suite struct ProgressViewWithLinearStyleTests { - #if canImport(UIKit) - typealias PlatformProgressViewWithLinearStyle = UIProgressView - #elseif canImport(AppKit) - typealias PlatformProgressViewWithLinearStyle = NSProgressIndicator - #endif + #if canImport(UIKit) + typealias PlatformProgressViewWithLinearStyle = UIProgressView + #elseif canImport(AppKit) + typealias PlatformProgressViewWithLinearStyle = NSProgressIndicator + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformProgressViewWithLinearStyle.self) { spy1, spy2, spy3 in - VStack { - ProgressView(value: 0.25) - .progressViewStyle(.linear) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.progressView(style: .linear), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.progressView(style: .linear), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformProgressViewWithLinearStyle.self) { spy1, spy2, spy3 in + VStack { + ProgressView(value: 0.25) + .progressViewStyle(.linear) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.progressView(style: .linear), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.progressView(style: .linear), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - ProgressView(value: 0.5) - .progressViewStyle(.linear) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.progressView(style: .linear), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.progressView(style: .linear), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + ProgressView(value: 0.5) + .progressViewStyle(.linear) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.progressView(style: .linear), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.progressView(style: .linear), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - ProgressView(value: 0.75) - .progressViewStyle(.linear) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.progressView(style: .linear), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.progressView(style: .linear), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.progress == 0.25) - #expect(entity2.progress == 0.5) - #expect(entity3.progress == 0.75) - #elseif canImport(AppKit) && !targetEnvironment(macCatalyst) - #expect(entity1.doubleValue == 0.25) - #expect(entity2.doubleValue == 0.5) - #expect(entity3.doubleValue == 0.75) - #endif - } + ProgressView(value: 0.75) + .progressViewStyle(.linear) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.progressView(style: .linear), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.progressView(style: .linear), on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.progress == 0.25) + #expect(entity2.progress == 0.5) + #expect(entity3.progress == 0.75) + #elseif canImport(AppKit) && !targetEnvironment(macCatalyst) + #expect(entity1.doubleValue == 0.25) + #expect(entity2.doubleValue == 0.5) + #expect(entity3.doubleValue == 0.75) + #endif + } } diff --git a/Tests/Tests/ViewTypes/ScrollViewTests.swift b/Tests/Tests/ViewTypes/ScrollViewTests.swift index 2059f9f2..edebb5d4 100644 --- a/Tests/Tests/ViewTypes/ScrollViewTests.swift +++ b/Tests/Tests/ViewTypes/ScrollViewTests.swift @@ -5,109 +5,109 @@ import Testing @MainActor @Suite struct ScrollViewTests { - #if canImport(UIKit) - typealias PlatformScrollView = UIScrollView - #elseif canImport(AppKit) - typealias PlatformScrollView = NSScrollView - #endif + #if canImport(UIKit) + typealias PlatformScrollView = UIScrollView + #elseif canImport(AppKit) + typealias PlatformScrollView = NSScrollView + #endif - @Test func introspect() async throws { - let (entity1, entity2) = try await introspection(of: PlatformScrollView.self) { spy1, spy2 in - HStack { - ScrollView(showsIndicators: false) { - Text("Item 1") - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2) = try await introspection(of: PlatformScrollView.self) { spy1, spy2 in + HStack { + ScrollView(showsIndicators: false) { + Text("Item 1") + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - ScrollView(showsIndicators: true) { - Text("Item 1") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) - #elseif os(macOS) - .introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) - #endif - } - } - } - #if canImport(UIKit) - #expect(entity1.showsVerticalScrollIndicator == false) - #expect(entity2.showsVerticalScrollIndicator == true) - #elseif canImport(AppKit) - #expect(entity1.verticalScroller == nil) - #expect(entity2.verticalScroller != nil) - #endif + ScrollView(showsIndicators: true) { + Text("Item 1") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) + #elseif os(macOS) + .introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) + #endif + } + } + } + #if canImport(UIKit) + #expect(entity1.showsVerticalScrollIndicator == false) + #expect(entity2.showsVerticalScrollIndicator == true) + #elseif canImport(AppKit) + #expect(entity1.verticalScroller == nil) + #expect(entity2.verticalScroller != nil) + #endif - #expect(entity1 !== entity2) - } + #expect(entity1 !== entity2) + } - @Test func introspectNested() async throws { - let (entity1, entity2) = try await introspection(of: PlatformScrollView.self) { spy1, spy2 in - ScrollView(showsIndicators: true) { - Text("Item 1") + @Test func introspectNested() async throws { + let (entity1, entity2) = try await introspection(of: PlatformScrollView.self) { spy1, spy2 in + ScrollView(showsIndicators: true) { + Text("Item 1") - ScrollView(showsIndicators: false) { - Text("Item 1") - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - } - #if canImport(UIKit) - #expect(entity1.showsVerticalScrollIndicator == true) - #expect(entity2.showsVerticalScrollIndicator == false) - #elseif canImport(AppKit) - #expect(entity1.verticalScroller != nil) - #expect(entity2.verticalScroller == nil) - #endif + ScrollView(showsIndicators: false) { + Text("Item 1") + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + } + #if canImport(UIKit) + #expect(entity1.showsVerticalScrollIndicator == true) + #expect(entity2.showsVerticalScrollIndicator == false) + #elseif canImport(AppKit) + #expect(entity1.verticalScroller != nil) + #expect(entity2.verticalScroller == nil) + #endif - #expect(entity1 !== entity2) - } + #expect(entity1 !== entity2) + } - @Test func introspectMasked() async throws { - let (entity1, entity2) = try await introspection(of: PlatformScrollView.self) { spy1, spy2 in - HStack { - ScrollView(showsIndicators: false) { - Text("Item 1") - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .clipped() - .clipShape(RoundedRectangle(cornerRadius: 20.0)) - .cornerRadius(2.0) + @Test func introspectMasked() async throws { + let (entity1, entity2) = try await introspection(of: PlatformScrollView.self) { spy1, spy2 in + HStack { + ScrollView(showsIndicators: false) { + Text("Item 1") + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .clipped() + .clipShape(RoundedRectangle(cornerRadius: 20.0)) + .cornerRadius(2.0) - ScrollView(showsIndicators: true) { - Text("Item 1") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) - #elseif os(macOS) - .introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) - #endif - } - } - } - #if canImport(UIKit) - #expect(entity1.showsVerticalScrollIndicator == false) - #expect(entity2.showsVerticalScrollIndicator == true) - #elseif canImport(AppKit) - #expect(entity1.verticalScroller == nil) - #expect(entity2.verticalScroller != nil) - #endif + ScrollView(showsIndicators: true) { + Text("Item 1") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2) + #elseif os(macOS) + .introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2) + #endif + } + } + } + #if canImport(UIKit) + #expect(entity1.showsVerticalScrollIndicator == false) + #expect(entity2.showsVerticalScrollIndicator == true) + #elseif canImport(AppKit) + #expect(entity1.verticalScroller == nil) + #expect(entity2.verticalScroller != nil) + #endif - #expect(entity1 !== entity2) - } + #expect(entity1 !== entity2) + } } diff --git a/Tests/Tests/ViewTypes/SearchFieldTests.swift b/Tests/Tests/ViewTypes/SearchFieldTests.swift index 7641cfc7..80b31741 100644 --- a/Tests/Tests/ViewTypes/SearchFieldTests.swift +++ b/Tests/Tests/ViewTypes/SearchFieldTests.swift @@ -6,168 +6,168 @@ import Testing @MainActor @Suite struct SearchFieldTests { - #if canImport(UIKit) - typealias PlatformSearchField = UISearchBar - #endif + #if canImport(UIKit) + typealias PlatformSearchField = UISearchBar + #endif - @available(iOS 15, tvOS 15, *) - @Test(.`disabled on iOS 26+ except for iPad`()) - func introspectInNavigationStack() async throws { - try await introspection(of: PlatformSearchField.self) { spy in - NavigationView { - Text("Customized") - .searchable(text: .constant("")) - } - .navigationViewStyle(.stack) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) - #endif - } - } + @available(iOS 15, tvOS 15, *) + @Test(.`disabled on iOS 26+ except for iPad`()) + func introspectInNavigationStack() async throws { + try await introspection(of: PlatformSearchField.self) { spy in + NavigationView { + Text("Customized") + .searchable(text: .constant("")) + } + .navigationViewStyle(.stack) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) + #endif + } + } - @available(iOS 26, tvOS 15, *) - @Test func introspectInNavigationStackInTabView() async throws { - try await introspection(of: PlatformSearchField.self) { spy in - TabView { - NavigationView { - Text("Customized") - .searchable(text: .constant("")) - } - .navigationViewStyle(.stack) - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) - #endif - } - } + @available(iOS 26, tvOS 15, *) + @Test func introspectInNavigationStackInTabView() async throws { + try await introspection(of: PlatformSearchField.self) { spy in + TabView { + NavigationView { + Text("Customized") + .searchable(text: .constant("")) + } + .navigationViewStyle(.stack) + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) + #endif + } + } - @available(iOS 15, tvOS 15, *) - @Test(.`disabled on iOS 26+ except for iPad`()) - func introspectInNavigationStackAsAncestor() async throws { - try await introspection(of: PlatformSearchField.self) { spy in - NavigationView { - Text("Customized") - .searchable(text: .constant("")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) - #endif - } - .navigationViewStyle(.stack) - } - } + @available(iOS 15, tvOS 15, *) + @Test(.`disabled on iOS 26+ except for iPad`()) + func introspectInNavigationStackAsAncestor() async throws { + try await introspection(of: PlatformSearchField.self) { spy in + NavigationView { + Text("Customized") + .searchable(text: .constant("")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) + #endif + } + .navigationViewStyle(.stack) + } + } - @available(iOS 26, tvOS 15, *) - @Test func introspectInNavigationStackInTabViewAsAncestor() async throws { - try await introspection(of: PlatformSearchField.self) { spy in - TabView { - NavigationView { - Text("Customized") - .searchable(text: .constant("")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) - #endif - } - .navigationViewStyle(.stack) - } - } - } + @available(iOS 26, tvOS 15, *) + @Test func introspectInNavigationStackInTabViewAsAncestor() async throws { + try await introspection(of: PlatformSearchField.self) { spy in + TabView { + NavigationView { + Text("Customized") + .searchable(text: .constant("")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) + #endif + } + .navigationViewStyle(.stack) + } + } + } - @available(iOS 15, tvOS 15, *) - @Test(.`disabled on iOS 26+ except for iPad`()) - func introspectInNavigationSplitView() async throws { - try await introspection(of: PlatformSearchField.self) { spy in - NavigationView { - Text("Customized") - .searchable(text: .constant("")) - } - .navigationViewStyle(DoubleColumnNavigationViewStyle()) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) - #endif - #if os(iOS) - // NB: this is necessary for introspection to work, because on iPad the search field is in the sidebar, which is initially hidden. - .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { - $0.preferredDisplayMode = .oneOverSecondary - } - #endif - } - } + @available(iOS 15, tvOS 15, *) + @Test(.`disabled on iOS 26+ except for iPad`()) + func introspectInNavigationSplitView() async throws { + try await introspection(of: PlatformSearchField.self) { spy in + NavigationView { + Text("Customized") + .searchable(text: .constant("")) + } + .navigationViewStyle(DoubleColumnNavigationViewStyle()) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) + #endif + #if os(iOS) + // NB: this is necessary for introspection to work, because on iPad the search field is in the sidebar, which is initially hidden. + .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { + $0.preferredDisplayMode = .oneOverSecondary + } + #endif + } + } - @available(iOS 26, tvOS 15, *) - @Test func introspectInNavigationSplitViewInTabView() async throws { - try await introspection(of: PlatformSearchField.self) { spy in - TabView { - NavigationView { - Text("Customized") - .searchable(text: .constant("")) - } - .navigationViewStyle(DoubleColumnNavigationViewStyle()) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) - #endif - #if os(iOS) - // NB: this is necessary for introspection to work, because on iPad the search field is in the sidebar, which is initially hidden. - .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { - $0.preferredDisplayMode = .oneOverSecondary - } - #endif - } - } - } + @available(iOS 26, tvOS 15, *) + @Test func introspectInNavigationSplitViewInTabView() async throws { + try await introspection(of: PlatformSearchField.self) { spy in + TabView { + NavigationView { + Text("Customized") + .searchable(text: .constant("")) + } + .navigationViewStyle(DoubleColumnNavigationViewStyle()) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) + #endif + #if os(iOS) + // NB: this is necessary for introspection to work, because on iPad the search field is in the sidebar, which is initially hidden. + .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { + $0.preferredDisplayMode = .oneOverSecondary + } + #endif + } + } + } - @available(iOS 15, tvOS 15, *) - @Test(.`disabled on iOS 26+ except for iPad`()) - func introspectInNavigationSplitViewAsAncestor() async throws { - try await introspection(of: PlatformSearchField.self) { spy in - NavigationView { - Text("Customized") - .searchable(text: .constant("")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) - #endif - } - .navigationViewStyle(DoubleColumnNavigationViewStyle()) - #if os(iOS) - // NB: this is necessary for introspection to work, because on iPad the search field is in the sidebar, which is initially hidden. - .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { - $0.preferredDisplayMode = .oneOverSecondary - } - #endif - } - } + @available(iOS 15, tvOS 15, *) + @Test(.`disabled on iOS 26+ except for iPad`()) + func introspectInNavigationSplitViewAsAncestor() async throws { + try await introspection(of: PlatformSearchField.self) { spy in + NavigationView { + Text("Customized") + .searchable(text: .constant("")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) + #endif + } + .navigationViewStyle(DoubleColumnNavigationViewStyle()) + #if os(iOS) + // NB: this is necessary for introspection to work, because on iPad the search field is in the sidebar, which is initially hidden. + .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { + $0.preferredDisplayMode = .oneOverSecondary + } + #endif + } + } - @available(iOS 26, tvOS 15, *) - @Test func introspectInNavigationSplitViewInTabViewAsAncestor() async throws { - try await introspection(of: PlatformSearchField.self) { spy in - TabView { - NavigationView { - Text("Customized") - .searchable(text: .constant("")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) - #endif - } - .navigationViewStyle(DoubleColumnNavigationViewStyle()) - #if os(iOS) - // NB: this is necessary for introspection to work, because on iPad the search field is in the sidebar, which is initially hidden. - .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { - $0.preferredDisplayMode = .oneOverSecondary - } - #endif - } - } - } + @available(iOS 26, tvOS 15, *) + @Test func introspectInNavigationSplitViewInTabViewAsAncestor() async throws { + try await introspection(of: PlatformSearchField.self) { spy in + TabView { + NavigationView { + Text("Customized") + .searchable(text: .constant("")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.searchField, on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) + #endif + } + .navigationViewStyle(DoubleColumnNavigationViewStyle()) + #if os(iOS) + // NB: this is necessary for introspection to work, because on iPad the search field is in the sidebar, which is initially hidden. + .introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { + $0.preferredDisplayMode = .oneOverSecondary + } + #endif + } + } + } } @MainActor extension Trait where Self == ConditionTrait { - static func `disabled on iOS 26+ except for iPad`(sourceLocation: SourceLocation = #_sourceLocation) -> Self { - let disabled = if #available(iOS 26, *) { - UIDevice.current.userInterfaceIdiom != .pad - } else { - false - } - return .disabled(if: disabled, "Disabled on iOS 26+ except for iPad", sourceLocation: sourceLocation) - } + static func `disabled on iOS 26+ except for iPad`(sourceLocation: SourceLocation = #_sourceLocation) -> Self { + let disabled = if #available(iOS 26, *) { + UIDevice.current.userInterfaceIdiom != .pad + } else { + false + } + return .disabled(if: disabled, "Disabled on iOS 26+ except for iPad", sourceLocation: sourceLocation) + } } #endif diff --git a/Tests/Tests/ViewTypes/SecureFieldTests.swift b/Tests/Tests/ViewTypes/SecureFieldTests.swift index db5dc4d6..6227ad90 100644 --- a/Tests/Tests/ViewTypes/SecureFieldTests.swift +++ b/Tests/Tests/ViewTypes/SecureFieldTests.swift @@ -5,83 +5,83 @@ import Testing @MainActor @Suite struct SecureFieldTests { - #if canImport(UIKit) - typealias PlatformSecureField = UITextField - #elseif canImport(AppKit) - typealias PlatformSecureField = NSTextField - #endif + #if canImport(UIKit) + typealias PlatformSecureField = UITextField + #elseif canImport(AppKit) + typealias PlatformSecureField = NSTextField + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformSecureField.self) { spy1, spy2, spy3 in - VStack { - SecureField("", text: .constant("Secure Field 1")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.secureField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.secureField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformSecureField.self) { spy1, spy2, spy3 in + VStack { + SecureField("", text: .constant("Secure Field 1")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.secureField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.secureField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - SecureField("", text: .constant("Secure Field 2")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.secureField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.secureField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + SecureField("", text: .constant("Secure Field 2")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.secureField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.secureField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - SecureField("", text: .constant("Secure Field 3")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.secureField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.secureField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.text == "Secure Field 1") - #expect(entity2.text == "Secure Field 2") - #expect(entity3.text == "Secure Field 3") - #elseif canImport(AppKit) - #expect(entity1.stringValue == "Secure Field 1") - #expect(entity2.stringValue == "Secure Field 2") - #expect(entity3.stringValue == "Secure Field 3") - #endif - } + SecureField("", text: .constant("Secure Field 3")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.secureField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.secureField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.text == "Secure Field 1") + #expect(entity2.text == "Secure Field 2") + #expect(entity3.text == "Secure Field 3") + #elseif canImport(AppKit) + #expect(entity1.stringValue == "Secure Field 1") + #expect(entity2.stringValue == "Secure Field 2") + #expect(entity3.stringValue == "Secure Field 3") + #endif + } - @Test func introspectEmbeddedInList() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformSecureField.self) { spy1, spy2, spy3 in - List { - SecureField("", text: .constant("Secure Field 1")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.secureField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.secureField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspectEmbeddedInList() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformSecureField.self) { spy1, spy2, spy3 in + List { + SecureField("", text: .constant("Secure Field 1")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.secureField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.secureField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - SecureField("", text: .constant("Secure Field 2")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.secureField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.secureField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + SecureField("", text: .constant("Secure Field 2")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.secureField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.secureField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - SecureField("", text: .constant("Secure Field 3")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.secureField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.secureField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.text == "Secure Field 1") - #expect(entity2.text == "Secure Field 2") - #expect(entity3.text == "Secure Field 3") - #elseif canImport(AppKit) - #expect(entity1.stringValue == "Secure Field 1") - #expect(entity2.stringValue == "Secure Field 2") - #expect(entity3.stringValue == "Secure Field 3") - #endif - } + SecureField("", text: .constant("Secure Field 3")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.secureField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.secureField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.text == "Secure Field 1") + #expect(entity2.text == "Secure Field 2") + #expect(entity3.text == "Secure Field 3") + #elseif canImport(AppKit) + #expect(entity1.stringValue == "Secure Field 1") + #expect(entity2.stringValue == "Secure Field 2") + #expect(entity3.stringValue == "Secure Field 3") + #endif + } } diff --git a/Tests/Tests/ViewTypes/SheetTests.swift b/Tests/Tests/ViewTypes/SheetTests.swift index 0cae40a6..7b82508c 100644 --- a/Tests/Tests/ViewTypes/SheetTests.swift +++ b/Tests/Tests/ViewTypes/SheetTests.swift @@ -6,63 +6,63 @@ import Testing @MainActor @Suite struct SheetTests { - #if os(iOS) - @Test func introspect() async throws { - try await introspection(of: UIPresentationController.self) { spy in - Text("Root") - .sheet(isPresented: .constant(true)) { - Text("Sheet") - .introspect( - .sheet, - on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), - customize: spy - ) - } - } - } + #if os(iOS) + @Test func introspect() async throws { + try await introspection(of: UIPresentationController.self) { spy in + Text("Root") + .sheet(isPresented: .constant(true)) { + Text("Sheet") + .introspect( + .sheet, + on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), + customize: spy + ) + } + } + } - @available(iOS 15, tvOS 15, *) - @Test func introspectAsSheetPresentationController() async throws { - try await introspection(of: UISheetPresentationController.self) { spy in - Text("Root") - .sheet(isPresented: .constant(true)) { - Text("Sheet") - .introspect( - .sheet, - on: .iOS(.v15, .v16, .v17, .v18, .v26), - customize: spy - ) - } - } - } - #elseif os(tvOS) - @Test func introspect() async throws { - try await introspection(of: UIPresentationController.self) { spy in - Text("Root") - .sheet(isPresented: .constant(true)) { - Text("Content") - .introspect( - .sheet, - on: .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), - customize: spy - ) - } - } - } - #elseif os(visionOS) - @Test func introspect() async throws { - try await introspection(of: UIPresentationController.self) { spy in - Text("Root") - .sheet(isPresented: .constant(true)) { - Text("Sheet") - .introspect( - .sheet, - on: .visionOS(.v1, .v2, .v26), - customize: spy - ) - } - } - } - #endif + @available(iOS 15, tvOS 15, *) + @Test func introspectAsSheetPresentationController() async throws { + try await introspection(of: UISheetPresentationController.self) { spy in + Text("Root") + .sheet(isPresented: .constant(true)) { + Text("Sheet") + .introspect( + .sheet, + on: .iOS(.v15, .v16, .v17, .v18, .v26), + customize: spy + ) + } + } + } + #elseif os(tvOS) + @Test func introspect() async throws { + try await introspection(of: UIPresentationController.self) { spy in + Text("Root") + .sheet(isPresented: .constant(true)) { + Text("Content") + .introspect( + .sheet, + on: .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), + customize: spy + ) + } + } + } + #elseif os(visionOS) + @Test func introspect() async throws { + try await introspection(of: UIPresentationController.self) { spy in + Text("Root") + .sheet(isPresented: .constant(true)) { + Text("Sheet") + .introspect( + .sheet, + on: .visionOS(.v1, .v2, .v26), + customize: spy + ) + } + } + } + #endif } #endif diff --git a/Tests/Tests/ViewTypes/SliderTests.swift b/Tests/Tests/ViewTypes/SliderTests.swift index 7d12e6e2..22e6cfc1 100644 --- a/Tests/Tests/ViewTypes/SliderTests.swift +++ b/Tests/Tests/ViewTypes/SliderTests.swift @@ -6,48 +6,48 @@ import Testing @MainActor @Suite struct SliderTests { - #if canImport(UIKit) - typealias PlatformSlider = UISlider - #elseif canImport(AppKit) - typealias PlatformSlider = NSSlider - #endif + #if canImport(UIKit) + typealias PlatformSlider = UISlider + #elseif canImport(AppKit) + typealias PlatformSlider = NSSlider + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformSlider.self) { spy1, spy2, spy3 in - VStack { - Slider(value: .constant(0.2), in: 0...1) - #if os(iOS) - .introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformSlider.self) { spy1, spy2, spy3 in + VStack { + Slider(value: .constant(0.2), in: 0...1) + #if os(iOS) + .introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - Slider(value: .constant(0.5), in: 0...1) - #if os(iOS) - .introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + Slider(value: .constant(0.5), in: 0...1) + #if os(iOS) + .introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - Slider(value: .constant(0.8), in: 0...1) - #if os(iOS) - .introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.value == 0.2) - #expect(entity2.value == 0.5) - #expect(entity3.value == 0.8) - #elseif canImport(AppKit) - #expect(entity1.floatValue == 0.2) - #expect(entity2.floatValue == 0.5) - #expect(entity3.floatValue == 0.8) - #endif - } + Slider(value: .constant(0.8), in: 0...1) + #if os(iOS) + .introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.value == 0.2) + #expect(entity2.value == 0.5) + #expect(entity3.value == 0.8) + #elseif canImport(AppKit) + #expect(entity1.floatValue == 0.2) + #expect(entity2.floatValue == 0.5) + #expect(entity3.floatValue == 0.8) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/StepperTests.swift b/Tests/Tests/ViewTypes/StepperTests.swift index ee3a89c8..24eb3cea 100644 --- a/Tests/Tests/ViewTypes/StepperTests.swift +++ b/Tests/Tests/ViewTypes/StepperTests.swift @@ -6,40 +6,40 @@ import Testing @MainActor @Suite struct StepperTests { - #if canImport(UIKit) - typealias PlatformStepper = UIStepper - #elseif canImport(AppKit) - typealias PlatformStepper = NSStepper - #endif + #if canImport(UIKit) + typealias PlatformStepper = UIStepper + #elseif canImport(AppKit) + typealias PlatformStepper = NSStepper + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformStepper.self) { spy1, spy2, spy3 in - VStack { - Stepper("", value: .constant(0), in: 0...10) - #if os(iOS) - .introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformStepper.self) { spy1, spy2, spy3 in + VStack { + Stepper("", value: .constant(0), in: 0...10) + #if os(iOS) + .introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - Stepper("", value: .constant(0), in: 0...10) - #if os(iOS) - .introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + Stepper("", value: .constant(0), in: 0...10) + #if os(iOS) + .introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - Stepper("", value: .constant(0), in: 0...10) - #if os(iOS) - .introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #expect(Set([entity1, entity2, entity3].map(ObjectIdentifier.init)).count == 3) - } + Stepper("", value: .constant(0), in: 0...10) + #if os(iOS) + .introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #expect(Set([entity1, entity2, entity3].map(ObjectIdentifier.init)).count == 3) + } } #endif diff --git a/Tests/Tests/ViewTypes/TabViewTests.swift b/Tests/Tests/ViewTypes/TabViewTests.swift index 46c330af..cada67bd 100644 --- a/Tests/Tests/ViewTypes/TabViewTests.swift +++ b/Tests/Tests/ViewTypes/TabViewTests.swift @@ -6,82 +6,82 @@ import Testing @MainActor @Suite struct TabViewTests { - #if canImport(UIKit) - typealias PlatformTabView = UITabBarController - #elseif canImport(AppKit) - typealias PlatformTabView = NSTabView - #endif + #if canImport(UIKit) + typealias PlatformTabView = UITabBarController + #elseif canImport(AppKit) + typealias PlatformTabView = NSTabView + #endif - @available(macOS, introduced: 10.15, obsoleted: 15) - @Test func introspect() async throws { - try await introspection(of: PlatformTabView.self) { spy in - TabView { - ZStack { - Color.red - Text("Something") - } - } - #if os(iOS) || os(tvOS) - .introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy) - #elseif os(macOS) - .introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy) - #endif - } - } + @available(macOS, introduced: 10.15, obsoleted: 15) + @Test func introspect() async throws { + try await introspection(of: PlatformTabView.self) { spy in + TabView { + ZStack { + Color.red + Text("Something") + } + } + #if os(iOS) || os(tvOS) + .introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy) + #elseif os(macOS) + .introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy) + #endif + } + } - @available(macOS, introduced: 10.15, obsoleted: 15) - @Test func introspectAsAncestor() async throws { - try await introspection(of: PlatformTabView.self) { spy in - TabView { - ZStack { - Color.red - Text("Something") - #if os(iOS) || os(tvOS) - .introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy) - #elseif os(macOS) - .introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), scope: .ancestor, customize: spy) - #endif - } - } - } - } + @available(macOS, introduced: 10.15, obsoleted: 15) + @Test func introspectAsAncestor() async throws { + try await introspection(of: PlatformTabView.self) { spy in + TabView { + ZStack { + Color.red + Text("Something") + #if os(iOS) || os(tvOS) + .introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy) + #elseif os(macOS) + .introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), scope: .ancestor, customize: spy) + #endif + } + } + } + } - @available(tvOS, unavailable) - @Test func introspectWithNonRootPlacement() async throws { - try await introspection(of: PlatformTabView.self) { spy in - GroupBox { - TabView { - ZStack { - Color.red - Text("Something") - } - } - #if os(iOS) || os(tvOS) - .introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy) - #elseif os(macOS) - .introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy) - #endif - } - } - } + @available(tvOS, unavailable) + @Test func introspectWithNonRootPlacement() async throws { + try await introspection(of: PlatformTabView.self) { spy in + GroupBox { + TabView { + ZStack { + Color.red + Text("Something") + } + } + #if os(iOS) || os(tvOS) + .introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy) + #elseif os(macOS) + .introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy) + #endif + } + } + } - @available(tvOS, unavailable) - @Test func introspectWithNonRootPlacementAsAncestor() async throws { - try await introspection(of: PlatformTabView.self) { spy in - GroupBox { - TabView { - ZStack { - Color.red - Text("Something") - #if os(iOS) || os(tvOS) - .introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy) - #elseif os(macOS) - .introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy) - #endif - } - } - } - } - } + @available(tvOS, unavailable) + @Test func introspectWithNonRootPlacementAsAncestor() async throws { + try await introspection(of: PlatformTabView.self) { spy in + GroupBox { + TabView { + ZStack { + Color.red + Text("Something") + #if os(iOS) || os(tvOS) + .introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy) + #elseif os(macOS) + .introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy) + #endif + } + } + } + } + } } #endif diff --git a/Tests/Tests/ViewTypes/TabViewWithPageStyleTests.swift b/Tests/Tests/ViewTypes/TabViewWithPageStyleTests.swift index e63bdf11..cf0ee236 100644 --- a/Tests/Tests/ViewTypes/TabViewWithPageStyleTests.swift +++ b/Tests/Tests/ViewTypes/TabViewWithPageStyleTests.swift @@ -6,34 +6,34 @@ import Testing @MainActor @Suite struct TabViewWithPageStyleTests { - #if canImport(UIKit) - typealias PlatformTabViewWithPageStyle = UICollectionView - #endif + #if canImport(UIKit) + typealias PlatformTabViewWithPageStyle = UICollectionView + #endif - @Test func introspect() async throws { - try await introspection(of: PlatformTabViewWithPageStyle.self) { spy in - TabView { - Text("Page 1").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.red) - Text("Page 2").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.blue) - } - .tabViewStyle(.page) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.tabView(style: .page), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) - #endif - } - } + @Test func introspect() async throws { + try await introspection(of: PlatformTabViewWithPageStyle.self) { spy in + TabView { + Text("Page 1").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.red) + Text("Page 2").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.blue) + } + .tabViewStyle(.page) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.tabView(style: .page), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy) + #endif + } + } - @Test func introspectAsAncestor() async throws { - try await introspection(of: PlatformTabViewWithPageStyle.self) { spy in - TabView { - Text("Page 1").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.red) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.tabView(style: .page), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) - #endif - Text("Page 2").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.blue) - } - .tabViewStyle(.page) - } - } + @Test func introspectAsAncestor() async throws { + try await introspection(of: PlatformTabViewWithPageStyle.self) { spy in + TabView { + Text("Page 1").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.red) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.tabView(style: .page), on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy) + #endif + Text("Page 2").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.blue) + } + .tabViewStyle(.page) + } + } } #endif diff --git a/Tests/Tests/ViewTypes/TableTests.swift b/Tests/Tests/ViewTypes/TableTests.swift index c9fdee06..5cadc74a 100644 --- a/Tests/Tests/ViewTypes/TableTests.swift +++ b/Tests/Tests/ViewTypes/TableTests.swift @@ -6,127 +6,127 @@ import Testing @MainActor @Suite struct TableTests { - #if canImport(UIKit) - typealias PlatformTable = UICollectionView - #elseif canImport(AppKit) - typealias PlatformTable = NSTableView - #endif + #if canImport(UIKit) + typealias PlatformTable = UICollectionView + #elseif canImport(AppKit) + typealias PlatformTable = NSTableView + #endif - @available(iOS 16, macOS 12, *) - @Test func introspect() async throws { - try await introspection(of: PlatformTable.self) { spy1, spy2, spy3 in - VStack { - TipTable() - #if os(iOS) || os(visionOS) - .introspect(.table, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @available(iOS 16, macOS 12, *) + @Test func introspect() async throws { + try await introspection(of: PlatformTable.self) { spy1, spy2, spy3 in + VStack { + TipTable() + #if os(iOS) || os(visionOS) + .introspect(.table, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - TipTable() - #if os(iOS) || os(visionOS) - .introspect(.table, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + TipTable() + #if os(iOS) || os(visionOS) + .introspect(.table, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - TipTable() - #if os(iOS) || os(visionOS) - .introspect(.table, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - } + TipTable() + #if os(iOS) || os(visionOS) + .introspect(.table, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + } - @available(iOS 16, macOS 12, *) - @Test func introspectWithInsetStyle() async throws { - try await introspection(of: PlatformTable.self) { spy1, spy2, spy3 in - VStack { - TipTable() - .tableStyle(.inset) - #if os(iOS) || os(visionOS) - .introspect(.table, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @available(iOS 16, macOS 12, *) + @Test func introspectWithInsetStyle() async throws { + try await introspection(of: PlatformTable.self) { spy1, spy2, spy3 in + VStack { + TipTable() + .tableStyle(.inset) + #if os(iOS) || os(visionOS) + .introspect(.table, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - TipTable() - .tableStyle(.inset) - #if os(iOS) || os(visionOS) - .introspect(.table, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + TipTable() + .tableStyle(.inset) + #if os(iOS) || os(visionOS) + .introspect(.table, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - TipTable() - .tableStyle(.inset) - #if os(iOS) || os(visionOS) - .introspect(.table, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - } + TipTable() + .tableStyle(.inset) + #if os(iOS) || os(visionOS) + .introspect(.table, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + } - #if os(macOS) - @available(macOS 12, *) - @Test func introspectWithBorderedStyle() async throws { - try await introspection(of: PlatformTable.self) { spy1, spy2, spy3 in - VStack { - TipTable() - .tableStyle(.bordered) - #if os(macOS) - .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + #if os(macOS) + @available(macOS 12, *) + @Test func introspectWithBorderedStyle() async throws { + try await introspection(of: PlatformTable.self) { spy1, spy2, spy3 in + VStack { + TipTable() + .tableStyle(.bordered) + #if os(macOS) + .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - TipTable() - .tableStyle(.bordered) - #if os(macOS) - .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + TipTable() + .tableStyle(.bordered) + #if os(macOS) + .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - TipTable() - .tableStyle(.bordered) - #if os(macOS) - .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - } - #endif + TipTable() + .tableStyle(.bordered) + #if os(macOS) + .introspect(.table, on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + } + #endif } @available(iOS 16, macOS 12, *) extension TableTests { - struct TipTable: View { - struct Purchase: Identifiable { - let price: Decimal - let id = UUID() - } + struct TipTable: View { + struct Purchase: Identifiable { + let price: Decimal + let id = UUID() + } - var body: some View { - Table(of: Purchase.self) { - TableColumn("Base price") { purchase in - Text(purchase.price, format: .currency(code: "USD")) - } - TableColumn("With 15% tip") { purchase in - Text(purchase.price * 1.15, format: .currency(code: "USD")) - } - TableColumn("With 20% tip") { purchase in - Text(purchase.price * 1.2, format: .currency(code: "USD")) - } - TableColumn("With 25% tip") { purchase in - Text(purchase.price * 1.25, format: .currency(code: "USD")) - } - } rows: { - TableRow(Purchase(price: 20)) - TableRow(Purchase(price: 50)) - TableRow(Purchase(price: 75)) - } - } - } + var body: some View { + Table(of: Purchase.self) { + TableColumn("Base price") { purchase in + Text(purchase.price, format: .currency(code: "USD")) + } + TableColumn("With 15% tip") { purchase in + Text(purchase.price * 1.15, format: .currency(code: "USD")) + } + TableColumn("With 20% tip") { purchase in + Text(purchase.price * 1.2, format: .currency(code: "USD")) + } + TableColumn("With 25% tip") { purchase in + Text(purchase.price * 1.25, format: .currency(code: "USD")) + } + } rows: { + TableRow(Purchase(price: 20)) + TableRow(Purchase(price: 50)) + TableRow(Purchase(price: 75)) + } + } + } } #endif diff --git a/Tests/Tests/ViewTypes/TextEditorTests.swift b/Tests/Tests/ViewTypes/TextEditorTests.swift index 8c32a347..c1c3b5a2 100644 --- a/Tests/Tests/ViewTypes/TextEditorTests.swift +++ b/Tests/Tests/ViewTypes/TextEditorTests.swift @@ -6,48 +6,48 @@ import Testing @MainActor @Suite struct TextEditorTests { - #if canImport(UIKit) - typealias PlatformTextEditor = UITextView - #elseif canImport(AppKit) - typealias PlatformTextEditor = NSTextView - #endif + #if canImport(UIKit) + typealias PlatformTextEditor = UITextView + #elseif canImport(AppKit) + typealias PlatformTextEditor = NSTextView + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformTextEditor.self) { spy1, spy2, spy3 in - VStack { - TextEditor(text: .constant("Text Field 0")) - #if os(iOS) || os(visionOS) - .introspect(.textEditor, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.textEditor, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformTextEditor.self) { spy1, spy2, spy3 in + VStack { + TextEditor(text: .constant("Text Field 0")) + #if os(iOS) || os(visionOS) + .introspect(.textEditor, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.textEditor, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - TextEditor(text: .constant("Text Field 1")) - #if os(iOS) || os(visionOS) - .introspect(.textEditor, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.textEditor, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + TextEditor(text: .constant("Text Field 1")) + #if os(iOS) || os(visionOS) + .introspect(.textEditor, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.textEditor, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - TextEditor(text: .constant("Text Field 2")) - #if os(iOS) || os(visionOS) - .introspect(.textEditor, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.textEditor, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.text == "Text Field 0") - #expect(entity2.text == "Text Field 1") - #expect(entity3.text == "Text Field 2") - #elseif canImport(AppKit) - #expect(entity1.string == "Text Field 0") - #expect(entity2.string == "Text Field 1") - #expect(entity3.string == "Text Field 2") - #endif - } + TextEditor(text: .constant("Text Field 2")) + #if os(iOS) || os(visionOS) + .introspect(.textEditor, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.textEditor, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.text == "Text Field 0") + #expect(entity2.text == "Text Field 1") + #expect(entity3.text == "Text Field 2") + #elseif canImport(AppKit) + #expect(entity1.string == "Text Field 0") + #expect(entity2.string == "Text Field 1") + #expect(entity3.string == "Text Field 2") + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/TextFieldTests.swift b/Tests/Tests/ViewTypes/TextFieldTests.swift index 169c6573..257d2edf 100644 --- a/Tests/Tests/ViewTypes/TextFieldTests.swift +++ b/Tests/Tests/ViewTypes/TextFieldTests.swift @@ -5,83 +5,83 @@ import Testing @MainActor @Suite struct TextFieldTests { - #if canImport(UIKit) - typealias PlatformTextField = UITextField - #elseif canImport(AppKit) - typealias PlatformTextField = NSTextField - #endif + #if canImport(UIKit) + typealias PlatformTextField = UITextField + #elseif canImport(AppKit) + typealias PlatformTextField = NSTextField + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformTextField.self) { spy1, spy2, spy3 in - VStack { - TextField("", text: .constant("Text Field 1")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformTextField.self) { spy1, spy2, spy3 in + VStack { + TextField("", text: .constant("Text Field 1")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - TextField("", text: .constant("Text Field 2")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + TextField("", text: .constant("Text Field 2")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - TextField("", text: .constant("Text Field 3")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.text == "Text Field 1") - #expect(entity2.text == "Text Field 2") - #expect(entity3.text == "Text Field 3") - #elseif canImport(AppKit) - #expect(entity1.stringValue == "Text Field 1") - #expect(entity2.stringValue == "Text Field 2") - #expect(entity3.stringValue == "Text Field 3") - #endif - } + TextField("", text: .constant("Text Field 3")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.text == "Text Field 1") + #expect(entity2.text == "Text Field 2") + #expect(entity3.text == "Text Field 3") + #elseif canImport(AppKit) + #expect(entity1.stringValue == "Text Field 1") + #expect(entity2.stringValue == "Text Field 2") + #expect(entity3.stringValue == "Text Field 3") + #endif + } - @Test func introspectEmbeddedInList() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformTextField.self) { spy1, spy2, spy3 in - List { - TextField("", text: .constant("Text Field 1")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspectEmbeddedInList() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformTextField.self) { spy1, spy2, spy3 in + List { + TextField("", text: .constant("Text Field 1")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - TextField("", text: .constant("Text Field 2")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + TextField("", text: .constant("Text Field 2")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - TextField("", text: .constant("Text Field 3")) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.text == "Text Field 1") - #expect(entity2.text == "Text Field 2") - #expect(entity3.text == "Text Field 3") - #elseif canImport(AppKit) - #expect(entity1.stringValue == "Text Field 1") - #expect(entity2.stringValue == "Text Field 2") - #expect(entity3.stringValue == "Text Field 3") - #endif - } + TextField("", text: .constant("Text Field 3")) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.text == "Text Field 1") + #expect(entity2.text == "Text Field 2") + #expect(entity3.text == "Text Field 3") + #elseif canImport(AppKit) + #expect(entity1.stringValue == "Text Field 1") + #expect(entity2.stringValue == "Text Field 2") + #expect(entity3.stringValue == "Text Field 3") + #endif + } } diff --git a/Tests/Tests/ViewTypes/TextFieldWithVerticalAxisTests.swift b/Tests/Tests/ViewTypes/TextFieldWithVerticalAxisTests.swift index c8078d4f..9ebd143f 100644 --- a/Tests/Tests/ViewTypes/TextFieldWithVerticalAxisTests.swift +++ b/Tests/Tests/ViewTypes/TextFieldWithVerticalAxisTests.swift @@ -5,56 +5,56 @@ import Testing @MainActor @Suite struct TextFieldWithVerticalAxisTests { - #if canImport(UIKit) && (os(iOS) || os(visionOS)) - typealias PlatformTextField = UITextView - #elseif canImport(UIKit) && os(tvOS) - typealias PlatformTextField = UITextField - #elseif canImport(AppKit) - typealias PlatformTextField = NSTextField - #endif + #if canImport(UIKit) && (os(iOS) || os(visionOS)) + typealias PlatformTextField = UITextView + #elseif canImport(UIKit) && os(tvOS) + typealias PlatformTextField = UITextField + #elseif canImport(AppKit) + typealias PlatformTextField = NSTextField + #endif - @available(iOS 16, tvOS 16, macOS 13, *) - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformTextField.self) { spy1, spy2, spy3 in - VStack { - TextField("", text: .constant("Text Field 1"), axis: .vertical) - #if os(iOS) || os(visionOS) - .introspect(.textField(axis: .vertical), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(tvOS) - .introspect(.textField(axis: .vertical), on: .tvOS(.v16, .v17, .v18, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.textField(axis: .vertical), on: .macOS(.v13, .v14, .v15, .v26), customize: spy1) - #endif - .cornerRadius(8) + @available(iOS 16, tvOS 16, macOS 13, *) + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformTextField.self) { spy1, spy2, spy3 in + VStack { + TextField("", text: .constant("Text Field 1"), axis: .vertical) + #if os(iOS) || os(visionOS) + .introspect(.textField(axis: .vertical), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(tvOS) + .introspect(.textField(axis: .vertical), on: .tvOS(.v16, .v17, .v18, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.textField(axis: .vertical), on: .macOS(.v13, .v14, .v15, .v26), customize: spy1) + #endif + .cornerRadius(8) - TextField("", text: .constant("Text Field 2"), axis: .vertical) - #if os(iOS) || os(visionOS) - .introspect(.textField(axis: .vertical), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(tvOS) - .introspect(.textField(axis: .vertical), on: .tvOS(.v16, .v17, .v18, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.textField(axis: .vertical), on: .macOS(.v13, .v14, .v15, .v26), customize: spy2) - #endif - .cornerRadius(8) + TextField("", text: .constant("Text Field 2"), axis: .vertical) + #if os(iOS) || os(visionOS) + .introspect(.textField(axis: .vertical), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(tvOS) + .introspect(.textField(axis: .vertical), on: .tvOS(.v16, .v17, .v18, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.textField(axis: .vertical), on: .macOS(.v13, .v14, .v15, .v26), customize: spy2) + #endif + .cornerRadius(8) - TextField("", text: .constant("Text Field 3"), axis: .vertical) - #if os(iOS) || os(visionOS) - .introspect(.textField(axis: .vertical), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(tvOS) - .introspect(.textField(axis: .vertical), on: .tvOS(.v16, .v17, .v18, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.textField(axis: .vertical), on: .macOS(.v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.text == "Text Field 1") - #expect(entity2.text == "Text Field 2") - #expect(entity3.text == "Text Field 3") - #elseif canImport(AppKit) - #expect(entity1.stringValue == "Text Field 1") - #expect(entity2.stringValue == "Text Field 2") - #expect(entity3.stringValue == "Text Field 3") - #endif - } + TextField("", text: .constant("Text Field 3"), axis: .vertical) + #if os(iOS) || os(visionOS) + .introspect(.textField(axis: .vertical), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(tvOS) + .introspect(.textField(axis: .vertical), on: .tvOS(.v16, .v17, .v18, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.textField(axis: .vertical), on: .macOS(.v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.text == "Text Field 1") + #expect(entity2.text == "Text Field 2") + #expect(entity3.text == "Text Field 3") + #elseif canImport(AppKit) + #expect(entity1.stringValue == "Text Field 1") + #expect(entity2.stringValue == "Text Field 2") + #expect(entity3.stringValue == "Text Field 3") + #endif + } } diff --git a/Tests/Tests/ViewTypes/ToggleTests.swift b/Tests/Tests/ViewTypes/ToggleTests.swift index c27dd0ca..90fb0bae 100644 --- a/Tests/Tests/ViewTypes/ToggleTests.swift +++ b/Tests/Tests/ViewTypes/ToggleTests.swift @@ -6,46 +6,46 @@ import Testing @MainActor @Suite struct ToggleTests { - #if canImport(UIKit) - typealias PlatformToggle = UISwitch - #elseif canImport(AppKit) - typealias PlatformToggle = NSButton - #endif + #if canImport(UIKit) + typealias PlatformToggle = UISwitch + #elseif canImport(AppKit) + typealias PlatformToggle = NSButton + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformToggle.self) { spy1, spy2, spy3 in - VStack { - Toggle("", isOn: .constant(true)) - #if os(iOS) - .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformToggle.self) { spy1, spy2, spy3 in + VStack { + Toggle("", isOn: .constant(true)) + #if os(iOS) + .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - Toggle("", isOn: .constant(false)) - #if os(iOS) - .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + Toggle("", isOn: .constant(false)) + #if os(iOS) + .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - Toggle("", isOn: .constant(true)) - #if os(iOS) - .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.isOn == true) - #expect(entity2.isOn == false) - #expect(entity3.isOn == true) - #elseif canImport(AppKit) - #expect(entity1.state == .on) - #expect(entity2.state == .off) - #expect(entity3.state == .on) - #endif - } + Toggle("", isOn: .constant(true)) + #if os(iOS) + .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.isOn == true) + #expect(entity2.isOn == false) + #expect(entity3.isOn == true) + #elseif canImport(AppKit) + #expect(entity1.state == .on) + #expect(entity2.state == .off) + #expect(entity3.state == .on) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/ToggleWithButtonStyleTests.swift b/Tests/Tests/ViewTypes/ToggleWithButtonStyleTests.swift index 2d64afbb..4ab0e2e5 100644 --- a/Tests/Tests/ViewTypes/ToggleWithButtonStyleTests.swift +++ b/Tests/Tests/ViewTypes/ToggleWithButtonStyleTests.swift @@ -6,38 +6,38 @@ import Testing @MainActor @Suite struct ToggleWithButtonStyleTests { - #if canImport(AppKit) && !targetEnvironment(macCatalyst) - typealias PlatformToggleWithButtonStyle = NSButton - #endif + #if canImport(AppKit) && !targetEnvironment(macCatalyst) + typealias PlatformToggleWithButtonStyle = NSButton + #endif - @available(macOS 12, *) - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformToggleWithButtonStyle.self) { spy1, spy2, spy3 in - VStack { - Toggle("", isOn: .constant(true)) - .toggleStyle(.button) - #if os(macOS) - .introspect(.toggle(style: .button), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @available(macOS 12, *) + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformToggleWithButtonStyle.self) { spy1, spy2, spy3 in + VStack { + Toggle("", isOn: .constant(true)) + .toggleStyle(.button) + #if os(macOS) + .introspect(.toggle(style: .button), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - Toggle("", isOn: .constant(false)) - .toggleStyle(.button) - #if os(macOS) - .introspect(.toggle(style: .button), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + Toggle("", isOn: .constant(false)) + .toggleStyle(.button) + #if os(macOS) + .introspect(.toggle(style: .button), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - Toggle("", isOn: .constant(true)) - .toggleStyle(.button) - #if os(macOS) - .introspect(.toggle(style: .button), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(AppKit) && !targetEnvironment(macCatalyst) - #expect(entity1.state == .on) - #expect(entity2.state == .off) - #expect(entity3.state == .on) - #endif - } + Toggle("", isOn: .constant(true)) + .toggleStyle(.button) + #if os(macOS) + .introspect(.toggle(style: .button), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(AppKit) && !targetEnvironment(macCatalyst) + #expect(entity1.state == .on) + #expect(entity2.state == .off) + #expect(entity3.state == .on) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/ToggleWithCheckboxStyleTests.swift b/Tests/Tests/ViewTypes/ToggleWithCheckboxStyleTests.swift index 02899242..70347d7f 100644 --- a/Tests/Tests/ViewTypes/ToggleWithCheckboxStyleTests.swift +++ b/Tests/Tests/ViewTypes/ToggleWithCheckboxStyleTests.swift @@ -6,37 +6,37 @@ import Testing @MainActor @Suite struct ToggleWithCheckboxStyleTests { - #if canImport(AppKit) && !targetEnvironment(macCatalyst) - typealias PlatformToggleWithCheckboxStyle = NSButton - #endif + #if canImport(AppKit) && !targetEnvironment(macCatalyst) + typealias PlatformToggleWithCheckboxStyle = NSButton + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformToggleWithCheckboxStyle.self) { spy1, spy2, spy3 in - VStack { - Toggle("", isOn: .constant(true)) - .toggleStyle(.checkbox) - #if os(macOS) - .introspect(.toggle(style: .checkbox), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformToggleWithCheckboxStyle.self) { spy1, spy2, spy3 in + VStack { + Toggle("", isOn: .constant(true)) + .toggleStyle(.checkbox) + #if os(macOS) + .introspect(.toggle(style: .checkbox), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - Toggle("", isOn: .constant(false)) - .toggleStyle(.checkbox) - #if os(macOS) - .introspect(.toggle(style: .checkbox), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + Toggle("", isOn: .constant(false)) + .toggleStyle(.checkbox) + #if os(macOS) + .introspect(.toggle(style: .checkbox), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - Toggle("", isOn: .constant(true)) - .toggleStyle(.checkbox) - #if os(macOS) - .introspect(.toggle(style: .checkbox), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(AppKit) && !targetEnvironment(macCatalyst) - #expect(entity1.state == .on) - #expect(entity2.state == .off) - #expect(entity3.state == .on) - #endif - } + Toggle("", isOn: .constant(true)) + .toggleStyle(.checkbox) + #if os(macOS) + .introspect(.toggle(style: .checkbox), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(AppKit) && !targetEnvironment(macCatalyst) + #expect(entity1.state == .on) + #expect(entity2.state == .off) + #expect(entity3.state == .on) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift b/Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift index bfd0365e..a92d16b1 100644 --- a/Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift +++ b/Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift @@ -6,49 +6,49 @@ import Testing @MainActor @Suite struct ToggleWithSwitchStyleTests { - #if canImport(UIKit) - typealias PlatformToggleWithSwitchStyle = UISwitch - #elseif canImport(AppKit) - typealias PlatformToggleWithSwitchStyle = NSSwitch - #endif + #if canImport(UIKit) + typealias PlatformToggleWithSwitchStyle = UISwitch + #elseif canImport(AppKit) + typealias PlatformToggleWithSwitchStyle = NSSwitch + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformToggleWithSwitchStyle.self) { spy1, spy2, spy3 in - VStack { - Toggle("", isOn: .constant(true)) - .toggleStyle(.switch) - #if os(iOS) - .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformToggleWithSwitchStyle.self) { spy1, spy2, spy3 in + VStack { + Toggle("", isOn: .constant(true)) + .toggleStyle(.switch) + #if os(iOS) + .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - Toggle("", isOn: .constant(false)) - .toggleStyle(.switch) - #if os(iOS) - .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + Toggle("", isOn: .constant(false)) + .toggleStyle(.switch) + #if os(iOS) + .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - Toggle("", isOn: .constant(true)) - .toggleStyle(.switch) - #if os(iOS) - .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #if canImport(UIKit) - #expect(entity1.isOn == true) - #expect(entity2.isOn == false) - #expect(entity3.isOn == true) - #elseif canImport(AppKit) - #expect(entity1.state == .on) - #expect(entity2.state == .off) - #expect(entity3.state == .on) - #endif - } + Toggle("", isOn: .constant(true)) + .toggleStyle(.switch) + #if os(iOS) + .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #if canImport(UIKit) + #expect(entity1.isOn == true) + #expect(entity2.isOn == false) + #expect(entity3.isOn == true) + #elseif canImport(AppKit) + #expect(entity1.state == .on) + #expect(entity2.state == .off) + #expect(entity3.state == .on) + #endif + } } #endif diff --git a/Tests/Tests/ViewTypes/VideoPlayerTests.swift b/Tests/Tests/ViewTypes/VideoPlayerTests.swift index 552e0a7b..92ab1f43 100644 --- a/Tests/Tests/ViewTypes/VideoPlayerTests.swift +++ b/Tests/Tests/ViewTypes/VideoPlayerTests.swift @@ -7,44 +7,44 @@ import Testing @MainActor @Suite struct VideoPlayerTests { - #if canImport(UIKit) - typealias PlatformVideoPlayer = AVPlayerViewController - #elseif canImport(AppKit) - typealias PlatformVideoPlayer = AVPlayerView - #endif + #if canImport(UIKit) + typealias PlatformVideoPlayer = AVPlayerViewController + #elseif canImport(AppKit) + typealias PlatformVideoPlayer = AVPlayerView + #endif - @Test func introspect() async throws { - let videoURL1 = URL(string: "https://bit.ly/swswift#1")! - let videoURL2 = URL(string: "https://bit.ly/swswift#2")! - let videoURL3 = URL(string: "https://bit.ly/swswift#3")! + @Test func introspect() async throws { + let videoURL1 = URL(string: "https://bit.ly/swswift#1")! + let videoURL2 = URL(string: "https://bit.ly/swswift#2")! + let videoURL3 = URL(string: "https://bit.ly/swswift#3")! - let (entity1, entity2, entity3) = try await introspection(of: PlatformVideoPlayer.self) { spy1, spy2, spy3 in - VStack { - VideoPlayer(player: AVPlayer(url: videoURL1)) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.videoPlayer, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.videoPlayer, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + let (entity1, entity2, entity3) = try await introspection(of: PlatformVideoPlayer.self) { spy1, spy2, spy3 in + VStack { + VideoPlayer(player: AVPlayer(url: videoURL1)) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.videoPlayer, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.videoPlayer, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - VideoPlayer(player: AVPlayer(url: videoURL2)) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.videoPlayer, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.videoPlayer, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif + VideoPlayer(player: AVPlayer(url: videoURL2)) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.videoPlayer, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.videoPlayer, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif - VideoPlayer(player: AVPlayer(url: videoURL3)) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.videoPlayer, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.videoPlayer, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - } - #expect((entity1.player?.currentItem?.asset as? AVURLAsset)?.url == videoURL1) - #expect((entity2.player?.currentItem?.asset as? AVURLAsset)?.url == videoURL2) - #expect((entity3.player?.currentItem?.asset as? AVURLAsset)?.url == videoURL3) - } + VideoPlayer(player: AVPlayer(url: videoURL3)) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.videoPlayer, on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.videoPlayer, on: .macOS(.v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + } + #expect((entity1.player?.currentItem?.asset as? AVURLAsset)?.url == videoURL1) + #expect((entity2.player?.currentItem?.asset as? AVURLAsset)?.url == videoURL2) + #expect((entity3.player?.currentItem?.asset as? AVURLAsset)?.url == videoURL3) + } } #endif diff --git a/Tests/Tests/ViewTypes/ViewControllerTests.swift b/Tests/Tests/ViewTypes/ViewControllerTests.swift index 78c27960..ba5c68ae 100644 --- a/Tests/Tests/ViewTypes/ViewControllerTests.swift +++ b/Tests/Tests/ViewTypes/ViewControllerTests.swift @@ -6,40 +6,40 @@ import Testing @MainActor @Suite struct ViewControllerTests { - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformViewController.self) { spy1, spy2, spy3 in - TabView { - NavigationView { - Text("Root").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.red) - .introspect( - .viewController, - on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), - customize: spy3 - ) - } - .navigationViewStyle(.stack) - .tabItem { - Image(systemName: "1.circle") - Text("Tab 1") - } - .introspect( - .viewController, - on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), - customize: spy2 - ) - } - .introspect( - .viewController, - on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), - customize: spy1 - ) - } - #if !os(visionOS) - #expect(entity1 is UITabBarController) - #endif - #expect(entity2 is UINavigationController) - #expect(String(describing: entity3).contains("UIHostingController")) - #expect(entity2 === entity3.parent) - } + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformViewController.self) { spy1, spy2, spy3 in + TabView { + NavigationView { + Text("Root").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.red) + .introspect( + .viewController, + on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), + customize: spy3 + ) + } + .navigationViewStyle(.stack) + .tabItem { + Image(systemName: "1.circle") + Text("Tab 1") + } + .introspect( + .viewController, + on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), + customize: spy2 + ) + } + .introspect( + .viewController, + on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), + customize: spy1 + ) + } + #if !os(visionOS) + #expect(entity1 is UITabBarController) + #endif + #expect(entity2 is UINavigationController) + #expect(String(describing: entity3).contains("UIHostingController")) + #expect(entity2 === entity3.parent) + } } #endif diff --git a/Tests/Tests/ViewTypes/ViewTests.swift b/Tests/Tests/ViewTypes/ViewTests.swift index d1866b0f..bc0cb463 100644 --- a/Tests/Tests/ViewTypes/ViewTests.swift +++ b/Tests/Tests/ViewTypes/ViewTests.swift @@ -5,57 +5,57 @@ import Testing @MainActor @Suite struct ViewTests { - @Test func introspect() async throws { - let (entity1, entity2) = try await introspection(of: PlatformView.self) { spy1, spy2 in - VStack(spacing: 10) { - SUTView().frame(height: 30) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.view, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.view, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif - - SUTView().frame(height: 40) - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.view, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.view, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - } - .padding(10) - } - #expect(entity1.frame.height == 30) - #expect(entity2.frame.height == 40) - } + @Test func introspect() async throws { + let (entity1, entity2) = try await introspection(of: PlatformView.self) { spy1, spy2 in + VStack(spacing: 10) { + SUTView().frame(height: 30) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.view, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.view, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif + + SUTView().frame(height: 40) + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.view, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.view, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + } + .padding(10) + } + #expect(entity1.frame.height == 30) + #expect(entity2.frame.height == 40) + } } struct SUTView: PlatformViewControllerRepresentable { - #if canImport(UIKit) - typealias UIViewControllerType = PlatformViewController - #elseif canImport(AppKit) - typealias NSViewControllerType = PlatformViewController - #endif + #if canImport(UIKit) + typealias UIViewControllerType = PlatformViewController + #elseif canImport(AppKit) + typealias NSViewControllerType = PlatformViewController + #endif - func makePlatformViewController(context: Context) -> PlatformViewController { - let controller = PlatformViewController(nibName: nil, bundle: nil) - controller.view.translatesAutoresizingMaskIntoConstraints = false + func makePlatformViewController(context: Context) -> PlatformViewController { + let controller = PlatformViewController(nibName: nil, bundle: nil) + controller.view.translatesAutoresizingMaskIntoConstraints = false - let widthConstraint = controller.view.widthAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude) - widthConstraint.priority = .defaultLow + let widthConstraint = controller.view.widthAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude) + widthConstraint.priority = .defaultLow - let heightConstraint = controller.view.heightAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude) - heightConstraint.priority = .defaultLow + let heightConstraint = controller.view.heightAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude) + heightConstraint.priority = .defaultLow - NSLayoutConstraint.activate([widthConstraint, heightConstraint]) + NSLayoutConstraint.activate([widthConstraint, heightConstraint]) - return controller - } + return controller + } - func updatePlatformViewController(_ controller: PlatformViewController, context: Context) { - // NO-OP - } + func updatePlatformViewController(_ controller: PlatformViewController, context: Context) { + // NO-OP + } - static func dismantlePlatformViewController(_ controller: PlatformViewController, coordinator: Coordinator) { - // NO-OP - } + static func dismantlePlatformViewController(_ controller: PlatformViewController, coordinator: Coordinator) { + // NO-OP + } } diff --git a/Tests/Tests/ViewTypes/WebViewTests.swift b/Tests/Tests/ViewTypes/WebViewTests.swift index dc7a1127..70ab59b8 100644 --- a/Tests/Tests/ViewTypes/WebViewTests.swift +++ b/Tests/Tests/ViewTypes/WebViewTests.swift @@ -7,35 +7,35 @@ import WebKit @MainActor @Suite struct WebViewTests { - @available(iOS 26, tvOS 26, macOS 26, visionOS 26, *) - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: WKWebView.self) { spy1, spy2, spy3 in - VStack { - WebView(url: nil) - .introspect( - .webView, - on: .iOS(.v26), .tvOS(.v26), .macOS(.v26), .visionOS(.v26), - customize: spy1 - ) + @available(iOS 26, tvOS 26, macOS 26, visionOS 26, *) + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: WKWebView.self) { spy1, spy2, spy3 in + VStack { + WebView(url: nil) + .introspect( + .webView, + on: .iOS(.v26), .tvOS(.v26), .macOS(.v26), .visionOS(.v26), + customize: spy1 + ) - WebView(url: nil) - .introspect( - .webView, - on: .iOS(.v26), .tvOS(.v26), .macOS(.v26), .visionOS(.v26), - customize: spy2 - ) + WebView(url: nil) + .introspect( + .webView, + on: .iOS(.v26), .tvOS(.v26), .macOS(.v26), .visionOS(.v26), + customize: spy2 + ) - WebView(url: nil) - .introspect( - .webView, - on: .iOS(.v26), .tvOS(.v26), .macOS(.v26), .visionOS(.v26), - customize: spy3 - ) - } - } - #expect(entity1 !== entity2) - #expect(entity1 !== entity3) - #expect(entity2 !== entity3) - } + WebView(url: nil) + .introspect( + .webView, + on: .iOS(.v26), .tvOS(.v26), .macOS(.v26), .visionOS(.v26), + customize: spy3 + ) + } + } + #expect(entity1 !== entity2) + #expect(entity1 !== entity3) + #expect(entity2 !== entity3) + } } #endif diff --git a/Tests/Tests/ViewTypes/WindowTests.swift b/Tests/Tests/ViewTypes/WindowTests.swift index 7bb18c97..ef234164 100644 --- a/Tests/Tests/ViewTypes/WindowTests.swift +++ b/Tests/Tests/ViewTypes/WindowTests.swift @@ -5,37 +5,37 @@ import Testing @MainActor @Suite struct WindowTests { - #if canImport(UIKit) - typealias PlatformWindow = UIWindow - #elseif canImport(AppKit) - typealias PlatformWindow = NSWindow - #endif + #if canImport(UIKit) + typealias PlatformWindow = UIWindow + #elseif canImport(AppKit) + typealias PlatformWindow = NSWindow + #endif - @Test func introspect() async throws { - let (entity1, entity2, entity3) = try await introspection(of: PlatformWindow.self) { spy1, spy2, spy3 in - VStack { - Image(systemName: "scribble") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.window, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) - #elseif os(macOS) - .introspect(.window, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) - #endif + @Test func introspect() async throws { + let (entity1, entity2, entity3) = try await introspection(of: PlatformWindow.self) { spy1, spy2, spy3 in + VStack { + Image(systemName: "scribble") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.window, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1) + #elseif os(macOS) + .introspect(.window, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) + #endif - Text("Text") - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.window, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) - #elseif os(macOS) - .introspect(.window, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) - #endif - } - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect(.window, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) - #elseif os(macOS) - .introspect(.window, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) - #endif - } - #expect(entity1 === entity2) - #expect(entity1 === entity3) - #expect(entity2 === entity3) - } + Text("Text") + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.window, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2) + #elseif os(macOS) + .introspect(.window, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) + #endif + } + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect(.window, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3) + #elseif os(macOS) + .introspect(.window, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) + #endif + } + #expect(entity1 === entity2) + #expect(entity1 === entity3) + #expect(entity2 === entity3) + } } diff --git a/Tests/Tests/WeakTests.swift b/Tests/Tests/WeakTests.swift index 36bf5986..7fead49c 100644 --- a/Tests/Tests/WeakTests.swift +++ b/Tests/Tests/WeakTests.swift @@ -3,55 +3,55 @@ import Testing @Suite struct WeakTests { - final class Foo {} - - var strongFoo: Foo? = Foo() - - @Test func Init_nil() { - @Weak var weakFoo: Foo? - #expect(weakFoo == nil) - } - - @Test func Init_nonNil() { - @Weak var weakFoo: Foo? = strongFoo - #expect(weakFoo === strongFoo) - } - - @Test func Assignment_nilToNil() { - @Weak var weakFoo: Foo? - weakFoo = nil - #expect(weakFoo == nil) - } - - @Test func Assignment_nilToNonNil() { - @Weak var weakFoo: Foo? - let otherFoo = Foo() - weakFoo = otherFoo - #expect(weakFoo === otherFoo) - } - - @Test func Assignment_nonNilToNil() { - @Weak var weakFoo: Foo? = strongFoo - weakFoo = nil - #expect(weakFoo == nil) - } - - @Test func Assignment_nonNilToNonNil() { - @Weak var weakFoo: Foo? = strongFoo - let otherFoo = Foo() - weakFoo = otherFoo - #expect(weakFoo === otherFoo) - } - - @Test mutating func IndirectAssignment_nonNilToNil() { - @Weak var weakFoo: Foo? = strongFoo - strongFoo = nil - #expect(weakFoo == nil) - } - - @Test mutating func IndirectAssignment_nonNilToNonNil() { - @Weak var weakFoo: Foo? = strongFoo - strongFoo = Foo() - #expect(weakFoo == nil) - } + final class Foo {} + + var strongFoo: Foo? = Foo() + + @Test func Init_nil() { + @Weak var weakFoo: Foo? + #expect(weakFoo == nil) + } + + @Test func Init_nonNil() { + @Weak var weakFoo: Foo? = strongFoo + #expect(weakFoo === strongFoo) + } + + @Test func Assignment_nilToNil() { + @Weak var weakFoo: Foo? + weakFoo = nil + #expect(weakFoo == nil) + } + + @Test func Assignment_nilToNonNil() { + @Weak var weakFoo: Foo? + let otherFoo = Foo() + weakFoo = otherFoo + #expect(weakFoo === otherFoo) + } + + @Test func Assignment_nonNilToNil() { + @Weak var weakFoo: Foo? = strongFoo + weakFoo = nil + #expect(weakFoo == nil) + } + + @Test func Assignment_nonNilToNonNil() { + @Weak var weakFoo: Foo? = strongFoo + let otherFoo = Foo() + weakFoo = otherFoo + #expect(weakFoo === otherFoo) + } + + @Test mutating func IndirectAssignment_nonNilToNil() { + @Weak var weakFoo: Foo? = strongFoo + strongFoo = nil + #expect(weakFoo == nil) + } + + @Test mutating func IndirectAssignment_nonNilToNonNil() { + @Weak var weakFoo: Foo? = strongFoo + strongFoo = Foo() + #expect(weakFoo == nil) + } } diff --git a/Tests/TestsHostApp/TestsHostApp.swift b/Tests/TestsHostApp/TestsHostApp.swift index 050f4177..abed6a52 100644 --- a/Tests/TestsHostApp/TestsHostApp.swift +++ b/Tests/TestsHostApp/TestsHostApp.swift @@ -2,9 +2,9 @@ import SwiftUI @main struct App: SwiftUI.App { - var body: some Scene { - WindowGroup { - EmptyView() - } - } + var body: some Scene { + WindowGroup { + EmptyView() + } + } } diff --git a/fastlane/Fastfile b/fastlane/Fastfile index fbcd3058..640be191 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -1,221 +1,221 @@ skip_docs devices = { - "ios" => { - 15 => ["iPhone 13 Pro (15.5)", "iPad Pro (11-inch) (3rd generation) (15.5)",], - 16 => ["iPhone 14 Pro (16.4)", "iPad Pro (11-inch) (4th generation) (16.4)"], - 17 => ["iPhone 15 Pro (17.5)", "iPad Pro 11-inch (M4) (17.5)"], - 18 => ["iPhone 16 Pro (18.6)", "iPad Pro 11-inch (M4) (18.6)"], - 26 => ["iPhone 16 Pro (26.0)", "iPad Pro 11-inch (M4) (26.0)"], - }, - "tvos" => { - 15 => ["Apple TV (15.4)"], - 16 => ["Apple TV (16.4)"], - 17 => ["Apple TV (17.5)"], - 18 => ["Apple TV (18.5)"], - 26 => ["Apple TV (26.0)"], - }, - "watchos" => { - 8 => ["Apple Watch Series 7 (45mm) (8.5)"], - 9 => ["Apple Watch Series 8 (45mm) (9.4)"], - 10 => ["Apple Watch Series 9 (45mm) (10.5)"], - 11 => ["Apple Watch Series 10 (42mm) (11.5)"], - 26 => ["Apple Watch Series 10 (42mm) (26.0)"], - }, - "visionos" => { - 1 => ["Apple Vision Pro (at 2732x2048) (1.2)"], - 2 => ["Apple Vision Pro (at 2732x2048) (2.5)"], - 26 => ["Apple Vision Pro (26.0)"], - }, + "ios" => { + 15 => ["iPhone 13 Pro (15.5)", "iPad Pro (11-inch) (3rd generation) (15.5)",], + 16 => ["iPhone 14 Pro (16.4)", "iPad Pro (11-inch) (4th generation) (16.4)"], + 17 => ["iPhone 15 Pro (17.5)", "iPad Pro 11-inch (M4) (17.5)"], + 18 => ["iPhone 16 Pro (18.6)", "iPad Pro 11-inch (M4) (18.6)"], + 26 => ["iPhone 16 Pro (26.0)", "iPad Pro 11-inch (M4) (26.0)"], + }, + "tvos" => { + 15 => ["Apple TV (15.4)"], + 16 => ["Apple TV (16.4)"], + 17 => ["Apple TV (17.5)"], + 18 => ["Apple TV (18.5)"], + 26 => ["Apple TV (26.0)"], + }, + "watchos" => { + 8 => ["Apple Watch Series 7 (45mm) (8.5)"], + 9 => ["Apple Watch Series 8 (45mm) (9.4)"], + 10 => ["Apple Watch Series 9 (45mm) (10.5)"], + 11 => ["Apple Watch Series 10 (42mm) (11.5)"], + 26 => ["Apple Watch Series 10 (42mm) (26.0)"], + }, + "visionos" => { + 1 => ["Apple Vision Pro (at 2732x2048) (1.2)"], + 2 => ["Apple Vision Pro (at 2732x2048) (2.5)"], + 26 => ["Apple Vision Pro (26.0)"], + }, } before_all do |lane, options| - next if lane == :create_simulators - create_simulators(platform: options[:platform], version: options[:version]) + next if lane == :create_simulators + create_simulators(platform: options[:platform], version: options[:version]) end lane :create_simulators do |options| - require 'json' - require 'set' - - # map Fastfile platform keys to display names used by CoreSimulator runtimes - platforms_to_os = { - "ios" => "iOS", - "tvos" => "tvOS", - "watchos" => "watchOS", - "visionos" => "visionOS", - } - - # Build lookup tables from CoreSimulator for robust name→identifier mapping - begin - # Build a set of existing simulator name+runtime pairs to prevent duplicates across OS versions - devices_json = sh("xcrun simctl list -j devices", log: false) - devices_list = JSON.parse(devices_json) - existing_pairs = Set.new - (devices_list["devices"] || {}).each do |runtime_key, arr| - Array(arr).each do |d| - name = d["name"] - next unless name && runtime_key - existing_pairs.add("#{name}||#{runtime_key}") - end - end - - list_json = sh("xcrun simctl list -j", log: false) - list = JSON.parse(list_json) - devtypes = list["devicetypes"] || [] - runtimes = list["runtimes"] || [] - rescue => e - UI.message("Failed to read simctl lists: #{e}") - devtypes = [] - runtimes = [] - existing_pairs = Set.new - end - - device_name_to_id = devtypes.each_with_object({}) do |dt, h| - name = dt["name"]; id = dt["identifier"] - h[name] = id if name && id - end - - runtime_name_to_id = runtimes.each_with_object({}) do |rt, h| - next unless rt["isAvailable"] - name = rt["name"]; id = rt["identifier"] - h[name] = id if name && id - end - - # Fallback builders when exact matches are not present in the lookup tables - build_device_type_id = proc do |device_name| - s = device_name.gsub(/[()]/, '').gsub(/\s+/, '-').gsub(/[^A-Za-z0-9-]/, '') - "com.apple.CoreSimulator.SimDeviceType.#{s}" - end - - build_runtime_id = proc do |os_name, version| - "com.apple.CoreSimulator.SimRuntime.#{os_name}-#{version.tr('.', '-')}" - end - - platform_opt = options && options[:platform] ? options[:platform].to_s.downcase : nil - version_opt = options && options[:version] ? options[:version].to_i : nil - - local_devices = if platform_opt && devices.key?(platform_opt) - subset_versions = devices[platform_opt] - if version_opt && subset_versions.key?(version_opt) - { platform_opt => { version_opt => subset_versions[version_opt] } } - else - { platform_opt => subset_versions } - end - else - devices - end - - local_devices.each do |platform, versions| - os_name = platforms_to_os[platform] - next if os_name.nil? - - versions.values.flatten.each do |descriptor| - # descriptor examples: - # "iPhone 14 Pro (16.4)" - # "iPad Pro (11-inch) (4th generation) (16.4)" - # "Apple Vision Pro (2.5)" - begin - # Parse trailing "(x.y)" and derive device name - if descriptor =~ /\s*\(([^()]+)\)\s*\z/ - runtime_version = $1 - device_name = descriptor.sub(/\s*\([^()]+\)\s*\z/, '') - else - UI.message("Could not parse runtime version from '#{descriptor}', skipping") - next - end - - runtime_name = "#{os_name} #{runtime_version}" - - device_type_id = device_name_to_id[device_name] || build_device_type_id.call(device_name) - runtime_id = runtime_name_to_id[runtime_name] || build_runtime_id.call(os_name, runtime_version) - - # Use the device name without the version suffix as the simulator name - sim_name = device_name - - pair_key = "#{sim_name}||#{runtime_id}" - if existing_pairs.include?(pair_key) - UI.message("Already exists: #{sim_name} (#{runtime_version}), skipping") - next - end - - sh(%(xcrun simctl create "#{sim_name}" "#{device_type_id}" "#{runtime_id}" || true)) - existing_pairs.add(pair_key) - rescue => e - UI.message("Skipping #{descriptor}: #{e}") - end - end - end + require 'json' + require 'set' + + # map Fastfile platform keys to display names used by CoreSimulator runtimes + platforms_to_os = { + "ios" => "iOS", + "tvos" => "tvOS", + "watchos" => "watchOS", + "visionos" => "visionOS", + } + + # Build lookup tables from CoreSimulator for robust name→identifier mapping + begin + # Build a set of existing simulator name+runtime pairs to prevent duplicates across OS versions + devices_json = sh("xcrun simctl list -j devices", log: false) + devices_list = JSON.parse(devices_json) + existing_pairs = Set.new + (devices_list["devices"] || {}).each do |runtime_key, arr| + Array(arr).each do |d| + name = d["name"] + next unless name && runtime_key + existing_pairs.add("#{name}||#{runtime_key}") + end + end + + list_json = sh("xcrun simctl list -j", log: false) + list = JSON.parse(list_json) + devtypes = list["devicetypes"] || [] + runtimes = list["runtimes"] || [] + rescue => e + UI.message("Failed to read simctl lists: #{e}") + devtypes = [] + runtimes = [] + existing_pairs = Set.new + end + + device_name_to_id = devtypes.each_with_object({}) do |dt, h| + name = dt["name"]; id = dt["identifier"] + h[name] = id if name && id + end + + runtime_name_to_id = runtimes.each_with_object({}) do |rt, h| + next unless rt["isAvailable"] + name = rt["name"]; id = rt["identifier"] + h[name] = id if name && id + end + + # Fallback builders when exact matches are not present in the lookup tables + build_device_type_id = proc do |device_name| + s = device_name.gsub(/[()]/, '').gsub(/\s+/, '-').gsub(/[^A-Za-z0-9-]/, '') + "com.apple.CoreSimulator.SimDeviceType.#{s}" + end + + build_runtime_id = proc do |os_name, version| + "com.apple.CoreSimulator.SimRuntime.#{os_name}-#{version.tr('.', '-')}" + end + + platform_opt = options && options[:platform] ? options[:platform].to_s.downcase : nil + version_opt = options && options[:version] ? options[:version].to_i : nil + + local_devices = if platform_opt && devices.key?(platform_opt) + subset_versions = devices[platform_opt] + if version_opt && subset_versions.key?(version_opt) + { platform_opt => { version_opt => subset_versions[version_opt] } } + else + { platform_opt => subset_versions } + end + else + devices + end + + local_devices.each do |platform, versions| + os_name = platforms_to_os[platform] + next if os_name.nil? + + versions.values.flatten.each do |descriptor| + # descriptor examples: + # "iPhone 14 Pro (16.4)" + # "iPad Pro (11-inch) (4th generation) (16.4)" + # "Apple Vision Pro (2.5)" + begin + # Parse trailing "(x.y)" and derive device name + if descriptor =~ /\s*\(([^()]+)\)\s*\z/ + runtime_version = $1 + device_name = descriptor.sub(/\s*\([^()]+\)\s*\z/, '') + else + UI.message("Could not parse runtime version from '#{descriptor}', skipping") + next + end + + runtime_name = "#{os_name} #{runtime_version}" + + device_type_id = device_name_to_id[device_name] || build_device_type_id.call(device_name) + runtime_id = runtime_name_to_id[runtime_name] || build_runtime_id.call(os_name, runtime_version) + + # Use the device name without the version suffix as the simulator name + sim_name = device_name + + pair_key = "#{sim_name}||#{runtime_id}" + if existing_pairs.include?(pair_key) + UI.message("Already exists: #{sim_name} (#{runtime_version}), skipping") + next + end + + sh(%(xcrun simctl create "#{sim_name}" "#{device_type_id}" "#{runtime_id}" || true)) + existing_pairs.add(pair_key) + rescue => e + UI.message("Skipping #{descriptor}: #{e}") + end + end + end end lane :build do |options| - platform = options[:platform].to_s.downcase - version = options[:version].to_i - scheme = options[:scheme].to_s - - unless scheme == "Showcase" || scheme == "SwiftUIIntrospect" - raise "Unsupported scheme: #{scheme}" - next - end - - if platform == "macos" - for destination in ["platform=macOS", "platform=macOS,variant=Mac Catalyst"] - build_app( - scheme: scheme, - destination: destination, - skip_archive: true, - skip_codesigning: true, - skip_package_ipa: true, - skip_profile_detection: true, - ) - end - else - run_tests( - configuration: "Debug", - build_for_testing: true, - scheme: scheme, - devices: devices[platform][version], - prelaunch_simulator: false, - ensure_devices_found: true, - force_quit_simulator: true, - disable_concurrent_testing: true, - ) - end + platform = options[:platform].to_s.downcase + version = options[:version].to_i + scheme = options[:scheme].to_s + + unless scheme == "Showcase" || scheme == "SwiftUIIntrospect" + raise "Unsupported scheme: #{scheme}" + next + end + + if platform == "macos" + for destination in ["platform=macOS", "platform=macOS,variant=Mac Catalyst"] + build_app( + scheme: scheme, + destination: destination, + skip_archive: true, + skip_codesigning: true, + skip_package_ipa: true, + skip_profile_detection: true, + ) + end + else + run_tests( + configuration: "Debug", + build_for_testing: true, + scheme: scheme, + devices: devices[platform][version], + prelaunch_simulator: false, + ensure_devices_found: true, + force_quit_simulator: true, + disable_concurrent_testing: true, + ) + end end lane :test do |options| - configuration = (options[:configuration] || "Debug").to_s - platform = options[:platform].to_s.downcase - version = options[:version].to_i - scheme = options[:scheme].to_s - - if platform == "macos" - run_tests( - configuration: configuration, - scheme: scheme, - destination: "platform=macOS", - catalyst_platform: "macos", - disable_slide_to_type: false, - prelaunch_simulator: false, - ensure_devices_found: true, - force_quit_simulator: false, - disable_concurrent_testing: true, - ) - else - unless ["SwiftUIIntrospectTests"].include?(scheme) - raise "Unsupported scheme: #{scheme}" - end - run_tests( - configuration: configuration, - scheme: scheme, - devices: devices[platform][version], - prelaunch_simulator: false, - ensure_devices_found: true, - force_quit_simulator: true, - reset_simulator: false, - disable_concurrent_testing: true, - result_bundle: true, - output_directory: Dir.pwd + "/test_output", - ) - end + configuration = (options[:configuration] || "Debug").to_s + platform = options[:platform].to_s.downcase + version = options[:version].to_i + scheme = options[:scheme].to_s + + if platform == "macos" + run_tests( + configuration: configuration, + scheme: scheme, + destination: "platform=macOS", + catalyst_platform: "macos", + disable_slide_to_type: false, + prelaunch_simulator: false, + ensure_devices_found: true, + force_quit_simulator: false, + disable_concurrent_testing: true, + ) + else + unless ["SwiftUIIntrospectTests"].include?(scheme) + raise "Unsupported scheme: #{scheme}" + end + run_tests( + configuration: configuration, + scheme: scheme, + devices: devices[platform][version], + prelaunch_simulator: false, + ensure_devices_found: true, + force_quit_simulator: true, + reset_simulator: false, + disable_concurrent_testing: true, + result_bundle: true, + output_directory: Dir.pwd + "/test_output", + ) + end end