This package provides introspected views that can be used to inspect the underlying *Kit element of a SwiftUI view.
- Swift 5.9+ (Xcode 15+)
- iOS 13+, macOS 10.15+
dependencies: [
.package(url: "https://github.com/0xWDG/Inspect.git", branch: "main"),
],
targets: [
.target(name: "MyTarget", dependencies: [
.product(name: "Inspect", package: "Inspect"),
]),
]
- In Xcode, open your project and navigate to File → Swift Packages → Add Package Dependency...
- Paste the repository URL (
https://github.com/0xWDG/Inspect
) and click Next. - Click Finish.
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()
}
}
We can get in touch via Twitter/X, Discord, Mastodon, Email, Website.