Swiftpack.co - ShawnBaek/XRay as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by ShawnBaek.
ShawnBaek/XRay 1.0.2
Xray is viewDebugging tool for iOS, tvOS, watchOS and macOS
⭐️ 10
🕓 10 weeks ago
iOS
.package(url: "https://github.com/ShawnBaek/XRay.git", from: "1.0.2")

XRay

XRay is view debugging tool for iOS. Currently, XRay can show all of the view hierarchies in UIKit. For SwiftUI, I'm working on it.

XRay helps you debugging view without using XCode's Debug View Hierarchy debug view

Demo

https://user-images.githubusercontent.com/12643700/170850041-0c024526-5d14-49c7-9ab5-7e09fe5e2397.mp4

How to Use

Use XRay in Debug mode only. I don't recommend using it with Swizzling function.

  1. Add XRay in your project
Screen Shot 2022-05-29 at 1 17 41 PM
  1. Set ScreenShot Notification (AppDelegate.swift)
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
    #if DEBUG
        NotificationCenter.default.addObserver(
            self, selector: #selector(screenshotTaken),
            name: UIApplication.userDidTakeScreenshotNotification, object: nil
        )
    #endif
        return true
    }

    #if DEBUG
    @objc func screenshotTaken() {
        guard let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
                let keyWindow = scene.keyWindow,
                let topViewController = keyWindow.topViewController() else {
            return
        }
        let xray = XRay(rootViewController: topViewController)
        xray.captureXray(classNameOption: .all)
        DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(5)) {
            xray.removeXray()
        }
    }
    #endif

ClassNameOption

func captureXray(classNameOption: ClassNameOption)

Labels

  • Red Label(Center): ViewController
  • Blue Label(trailing bottom): Custom View
  • Black Label(leading top): View

ClassNameOption.all

This option shows all of the view hierarchies.

ClassNameOption.customClass

This option shows custom view only

Reference

GitHub

link
Stars: 10
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

10 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics