0xWDG/Inspect
This package provides introspected views that can be used to inspect the underlying *Kit element of a SwiftUI view.
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)
- 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.
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
π¦ @0xWDG π mastodon.social/@0xWDG π¦ @0xWDG π§΅ @0xWDG π wesleydegroot.nl π€ Discord
Interested learning more about Swift? Check out my blog.
Package Metadata
Repository: 0xWDG/Inspect
Homepage: https://0xwdg.github.io/Inspect/
Stars: 3
Forks: 0
Open issues: 0
Default branch: main
Primary language: swift
License: MIT
Topics: 0xwdg, hacktoberfest, inspect, introspect, spm, swift, swiftlang, swiftui
README: README.md