Skip to content
/ Inspect Public

This package provides introspected views that can be used to inspect the underlying *Kit element of a SwiftUI view.

License

Notifications You must be signed in to change notification settings

0xWDG/Inspect

Repository files navigation

Inspect

This package provides introspected views that can be used to inspect the underlying *Kit element of a SwiftUI view.

Swift Package Manager License

Requirements

  • Swift 5.9+ (Xcode 15+)
  • iOS 13+, macOS 10.15+

Installation (Pakage.swift)

dependencies: [
    .package(url: "https://github.com/0xWDG/Inspect.git", branch: "main"),
],
targets: [
    .target(name: "MyTarget", dependencies: [
        .product(name: "Inspect", package: "Inspect"),
    ]),
]

Installation (Xcode)

  1. In Xcode, open your project and navigate to FileSwift PackagesAdd Package Dependency...
  2. Paste the repository URL (https://github.com/0xWDG/Inspect) and click Next.
  3. Click Finish.

Usage

Example to read a ImageView (Multi platform):

import SwiftUI
import Inspect

struct ContentView: View {
#if os(macOS)
    let PlatformImageView = NSImageView.self
#else
    let PlatformImageView = UIImageView.self
#endif

    var body: some View {
        VStack {
            Image(systemName: "star")
                .inspect(PlatformImageView) { view in
                    print(view)
                }
        }
        .padding()
    }
}

Example to read a View Controller (iOS):

    var body: some View {
        List {
            Text("Item 1")
            Text("Item 2")
            Text("Item 3")
            Text("Item 4")
            Text("Item 5")
        }
        .inspectVC({ $0.tabBarController }) { view
            print(view)
        }
        .padding()
    }
}

Contact

We can get in touch via Twitter/X, Discord, Mastodon, Email, Website.