Skip to content

ShawnBaek/XRay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

XRay.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

About

Xray is viewDebugging tool for iOS, tvOS, watchOS and macOS

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages