Skip to content

Deprecate Introspect module #272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Changelog

## master

### SwiftUIIntrospect

- Added: window introspection (#269)
- Added: `.sheet` introspection (#268)
- Added: `.fullScreenCover` introspection (#268)
Expand All @@ -12,6 +14,10 @@ Changelog
- Added: `View` introspection on macOS (#266)
- Improved: `View` introspection accuracy (#266)

### Introspect

This module is now deprecated (#272) and will be removed later this year (whenever iOS/tvOS 17 come out).

## [0.6.3]

### SwiftUIIntrospect
Expand Down
39 changes: 37 additions & 2 deletions Introspect/ViewExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ extension View {

#if canImport(UIKit)
extension View {

/// Finds a `TargetView` from a `SwiftUI.View`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspect<TargetView: UIView>(
selector: @escaping (IntrospectionUIView) -> TargetView?,
customize: @escaping (TargetView) -> ()
Expand All @@ -25,8 +26,9 @@ extension View {
customize: customize
))
}

/// Finds a `UINavigationController` from any view embedded in a `SwiftUI.NavigationView`.
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectNavigationController(customize: @escaping (UINavigationController) -> ()) -> some View {
inject(UIKitIntrospectionViewController(
selector: { introspectionViewController in
Expand All @@ -44,6 +46,7 @@ extension View {
}

/// Finds a `UISplitViewController` from a `SwiftUI.NavigationView` with style `DoubleColumnNavigationViewStyle`.
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectSplitViewController(customize: @escaping (UISplitViewController) -> ()) -> some View {
inject(UIKitIntrospectionViewController(
selector: { introspectionViewController in
Expand All @@ -61,6 +64,7 @@ extension View {
}

/// Finds the containing `UIViewController` of a SwiftUI view.
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectViewController(customize: @escaping (UIViewController) -> ()) -> some View {
inject(UIKitIntrospectionViewController(
selector: { $0.parent },
Expand All @@ -69,6 +73,7 @@ extension View {
}

/// Finds a `UITabBarController` from any SwiftUI view embedded in a `SwiftUI.TabView`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectTabBarController(customize: @escaping (UITabBarController) -> ()) -> some View {
inject(UIKitIntrospectionViewController(
selector: { introspectionViewController in
Expand All @@ -88,6 +93,7 @@ extension View {
/// Finds a `UISearchController` from a `SwiftUI.View` with a `.searchable` modifier
@available(iOS 15, *)
@available(tvOS, unavailable)
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectSearchController(customize: @escaping (UISearchController) -> ()) -> some View {
introspectNavigationController { navigationController in
let navigationBar = navigationController.navigationBar
Expand All @@ -98,26 +104,31 @@ extension View {
}

/// Finds a `UITableView` from a `SwiftUI.List`, or `SwiftUI.List` child.
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectTableView(customize: @escaping (UITableView) -> ()) -> some View {
introspect(selector: TargetViewSelector.ancestorOrSiblingContaining, customize: customize)
}

/// Finds a `UITableViewCell` from a `SwiftUI.List`, or `SwiftUI.List` child. You can attach this directly to the element inside the list.
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectTableViewCell(customize: @escaping (UITableViewCell) -> ()) -> some View {
introspect(selector: TargetViewSelector.ancestorOrSiblingContaining, customize: customize)
}

/// Finds a `UICollectionView` from a `SwiftUI.List`, or `SwiftUI.List` child.
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectCollectionView(customize: @escaping (UICollectionView) -> ()) -> some View {
introspect(selector: TargetViewSelector.ancestorOrSiblingContaining, customize: customize)
}

/// Finds a `UICollectionView` from a `SwiftUI.List`, or `SwiftUI.List` child. You can attach this directly to the element inside the list.
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectCollectionViewCell(customize: @escaping (UICollectionViewCell) -> ()) -> some View {
introspect(selector: TargetViewSelector.ancestorOrSiblingContaining, customize: customize)
}

/// Finds a `UIScrollView` from a `SwiftUI.ScrollView`, or `SwiftUI.ScrollView` child.
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectScrollView(customize: @escaping (UIScrollView) -> ()) -> some View {
if #available(iOS 14, tvOS 14, *) {
return introspect(selector: TargetViewSelector.siblingOrAncestorOrSiblingContainingOrAncestorChild, customize: customize)
Expand All @@ -130,6 +141,7 @@ extension View {
///
/// Customize is called with a `UICollectionView` wrapper, and the horizontal `UIScrollView`.
@available(iOS 14, tvOS 14, *)
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectPagedTabView(customize: @escaping (UICollectionView, UIScrollView) -> ()) -> some View {
if #available(iOS 16, *) {
return introspect(selector: TargetViewSelector.ancestorOrSiblingContaining, customize: { (collectionView: UICollectionView) in
Expand All @@ -148,40 +160,47 @@ extension View {
}

/// Finds a `UITextField` from a `SwiftUI.TextField`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectTextField(customize: @escaping (UITextField) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContainingOrAncestorOrAncestorChild, customize: customize)
}

/// Finds a `UITextView` from a `SwiftUI.TextEditor`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectTextView(customize: @escaping (UITextView) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `UISwitch` from a `SwiftUI.Toggle`
@available(tvOS, unavailable)
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectSwitch(customize: @escaping (UISwitch) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `UISlider` from a `SwiftUI.Slider`
@available(tvOS, unavailable)
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectSlider(customize: @escaping (UISlider) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `UIStepper` from a `SwiftUI.Stepper`
@available(tvOS, unavailable)
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectStepper(customize: @escaping (UIStepper) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `UIDatePicker` from a `SwiftUI.DatePicker`
@available(tvOS, unavailable)
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectDatePicker(customize: @escaping (UIDatePicker) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `UISegmentedControl` from a `SwiftUI.Picker` with style `SegmentedPickerStyle`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectSegmentedControl(customize: @escaping (UISegmentedControl) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}
Expand All @@ -190,6 +209,7 @@ extension View {
#if os(iOS)
@available(iOS 14, *)
@available(tvOS, unavailable)
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectColorWell(customize: @escaping (UIColorWell) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}
Expand All @@ -201,6 +221,7 @@ extension View {
extension View {

/// Finds a `TargetView` from a `SwiftUI.View`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspect<TargetView: NSView>(
selector: @escaping (IntrospectionNSView) -> TargetView?,
customize: @escaping (TargetView) -> ()
Expand All @@ -212,21 +233,25 @@ extension View {
}

/// Finds a `NSSplitViewController` from a `SwiftUI.NavigationView` with style `DoubleColumnNavigationViewStyle`.
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectSplitView(customize: @escaping (NSSplitView) -> ()) -> some View {
return introspect(selector: TargetViewSelector.ancestorOrSiblingContaining, customize: customize)
}

/// Finds a `NSTableView` from a `SwiftUI.List`, or `SwiftUI.List` child.
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectTableView(customize: @escaping (NSTableView) -> ()) -> some View {
introspect(selector: TargetViewSelector.ancestorOrSiblingContaining, customize: customize)
}

/// Finds a `NSTableCellView` from a `SwiftUI.List`, or `SwiftUI.List` child. You can attach this directly to the element inside the list.
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectTableViewCell(customize: @escaping (NSTableCellView) -> ()) -> some View {
introspect(selector: TargetViewSelector.ancestorOrSiblingContaining, customize: customize)
}

/// Finds a `NSScrollView` from a `SwiftUI.ScrollView`, or `SwiftUI.ScrollView` child.
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectScrollView(customize: @escaping (NSScrollView) -> ()) -> some View {
if #available(macOS 11, *) {
return introspect(selector: TargetViewSelector.siblingOrAncestorOrSiblingContainingOrAncestorChild, customize: customize)
Expand All @@ -236,47 +261,56 @@ extension View {
}

/// Finds a `NSTextField` from a `SwiftUI.TextField`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectTextField(customize: @escaping (NSTextField) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `NSTextView` from a `SwiftUI.TextView`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectTextView(customize: @escaping (NSTextView) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `NSSlider` from a `SwiftUI.Slider`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectSlider(customize: @escaping (NSSlider) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `NSStepper` from a `SwiftUI.Stepper`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectStepper(customize: @escaping (NSStepper) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `NSDatePicker` from a `SwiftUI.DatePicker`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectDatePicker(customize: @escaping (NSDatePicker) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `NSSegmentedControl` from a `SwiftUI.Picker` with style `SegmentedPickerStyle`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectSegmentedControl(customize: @escaping (NSSegmentedControl) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `NSTabView` from a `SwiftUI.TabView`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectTabView(customize: @escaping (NSTabView) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `NSButton` from a `SwiftUI.Button`
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectButton(customize: @escaping (NSButton) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}

/// Finds a `NSColorWell` from a `SwiftUI.ColorPicker`
@available(macOS 11, *)
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectColorWell(customize: @escaping (NSColorWell) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}
Expand All @@ -289,6 +323,7 @@ import MapKit
extension View {
/// Finds an `MKMapView` from a `SwiftUI.Map`
@available(iOS 14, tvOS 14, macOS 11, *)
@available(*, deprecated, message: "The Introspect module is deprecated and will be obsoleted later this year. Please switch over to the new and improved SwiftUIIntrospect module. More info: https://github.com/siteline/swiftui-introspect#readme")
public func introspectMapView(customize: @escaping (MKMapView) -> ()) -> some View {
introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
}
Expand Down