• Stars
    star
    1,871
  • Rank 24,773 (Top 0.5 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 5 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A UIView debugger (like Reveal or Xcode) that can be embedded in an app for on-device view debugging

InAppViewDebugger

License CocoaPods Carthage compatible

InAppViewDebugger

InAppViewDebugger is a library that implements a view debugger with a 3D snapshot view and a hierarchy view, similar to Reveal and Xcode's own view debugger. The key distinction is, as the project title suggests, that this can be embedded inside the app and used on-device to debug UI issues without needing to be tethered to a computer.

Features

  • 3D snapshot view implemented in SceneKit: Gesture controls for zooming, panning, and rotating.
  • Hierarchy (tree) view that synchronizes its selection with the 3D view: This is a feature I really wanted in Xcode, to be able to visually find a view and see where it is in the hierarchy view
  • Support for iPad and iPhone: Layouts are designed specifically for each form factor.
  • Extensible: The base implementation supports UIView hierarchies, but this is easily extensible to support any kind of UI framework (e.g. CoreAnimation or SpriteKit)

Requirements

  • iOS 11.0+
  • Xcode 10.1+ (framework built for Swift 4.2)

Installation

CocoaPods

Add the following line to your Podfile:

pod 'InAppViewDebugger', '~> 1.0.3'

Carthage

Add the following line to your Cartfile:

github "indragiek/InAppViewDebugger" "1.0.3"

Usage

Swift

import InAppViewDebugger

@IBAction func showViewDebugger(sender: AnyObject) {
  InAppViewDebugger.present()
}

Objective-C

@import InAppViewDebugger;

// alternative import (they're the same):
// #import <InAppViewDebugger/InAppViewDebugger-Swift.h>

- (IBAction)showViewDebugger:(id)sender {
  [InAppViewDebugger present];
}

lldb

(lldb) expr -lswift -- import InAppViewDebugger
(lldb) expr -lswift -- InAppViewDebugger.present()

The present function shows the UI hierarchy for your application's key window, presented over the top view controller of the window's root view controller. There are several other methods available on InAppViewDebugger for presenting a view debugger for a given window, view, or view controller.

Controls

Focusing on an Element

To focus on the subhierarchy of a particular element, long press on the element to bring up the action menu and tap "Focus". The long press can be used both in the hierarchy view and the 3D snapshot view. The "Log Description" action will log the description of the element to the console, so that if you're attached to Xcode you can copy the address of the object for further debugging.

Focusing on an Element

Adjusting Distance Between Levels

The slider on the bottom left of the snapshot view can be used to adjust the spacing between levels of the hierarchy:

Adjusting Distance Between Levels

Adjusting Visible Levels

The range slider on the bottom right of the snapshot view can be used to adjust the range of levels in the hierarchy that are visible:

Adjusting Visible Levels

Showing/Hiding Headers

Each UI element has a header above it that shows its class name. These headers can be hidden or shown by long pressing on an empty area of the snapshot view to bring up the action menu:

Showing/Hiding Headers

Showing/Hiding Borders

Similarly to the headers, the borders drawn around each element can also be shown or hidden:

Showing/Hiding Borders

Customization

Colors, fonts, and other attributes for both the snapshot view and the hierarchy view can be changed by creating a custom Configuration. The configuration is then passed to a function like InAppViewDebugger.presentForWindow(:configuration:completion:).

Extending for Other UI Frameworks

The current implementation only supports UIView hierarchies, but this can easily be extended to support other UI frameworks by conforming to the Element protocol. See ViewElement to see what an example implementation looks like β€” by providing a the frame, a snapshot image, and a few other pieces of information, all of the features described above will work for your own framework.

A Snapshot instance represents a recursive snapshot of the current state of a UI element hierarchy, and is constructed using an Element. The snapshot can then be passed to

InAppViewDebugger.presentWithSnapshot(:rootViewController:configuration:completion:)

to show the view debugger.

Credits

  • Kyle Van Essen for this tweet picturing Square's implementation that inspired me to build this
  • AudioKit SynthOne, an amazing open-source audio synthesizer app for the iPad that made for a great demo as pictured above

Contact

License

InAppViewDebugger is licensed under the MIT License. See LICENSE for more information.

More Repositories

1

CocoaMarkdown

Markdown parsing and rendering for iOS and OS X
Objective-C
1,200
star
2

INAppStoreWindow

NSWindow subclass with a highly customizable title bar and traffic lights
Objective-C
1,064
star
3

DominantColor

Finding dominant colors of an image using k-means clustering
Swift
959
star
4

MarkdownTextView

Rich Markdown editing control for iOS
Swift
686
star
5

SwiftAutoLayout

Tiny Swift DSL for Autolayout
Swift
655
star
6

SNRHUDKit

Code drawn AppKit HUD interface elements
Objective-C
326
star
7

swiftrsrc

Resource code generation tool for Swift
Swift
290
star
8

INDANCSClient

Objective-C Apple Notification Center Service Client
Objective-C
252
star
9

INPopoverController

A customizable popover controller for OS X
Objective-C
196
star
10

SNRSearchIndex

SearchKit backed search for Core Data
Objective-C
190
star
11

Unzip

iOS 8 Action Extension for browsing ZIP files
Objective-C
165
star
12

NSUserNotificationPrivate

Private API showcase for NSUserNotification on OS X
Objective-C
152
star
13

SNRMusicKit

All-in-one framework for browsing and playing music from various sources on iOS and OS X
Objective-C
150
star
14

WWDC-2014

Scholarship submission for WWDC 2014
Objective-C
146
star
15

Ares

Zero-setup P2P file transfer between Macs and iOS devices
Swift
133
star
16

INDockableWindow

A window to which other views can be "docked" to and separated into their own windows
Objective-C
114
star
17

INDLinkLabel

A simple, no frills UILabel subclass with support for links
Swift
82
star
18

SNRFetchedResultsController

Automatic Core Data change tracking for OS X (NSFetchedResultsController port)
Objective-C
81
star
19

INDSequentialTextSelectionManager

Sequential text selection for NSTextViews
Objective-C
74
star
20

OEGridView

High performance Core Animation-based grid view, originally from OpenEmu.
Objective-C
72
star
21

INDGIFPreviewDownloader

[iOS] Retrieves preview images for GIFs by downloading only the first frame
Objective-C
60
star
22

Chip8

CHIP-8 emulator and disassembler written in Swift
Swift
53
star
23

pdfcat

OS X utility for concatenating PDF files
Swift
49
star
24

ReactiveXPC

Signals across process boundaries
Swift
36
star
25

ObjectiveKVDB

Objective-C wrapper for kvdb (https://github.com/dinhviethoa/kvdb)
Objective-C
33
star
26

SwiftTableViews

Type-safe Table Views with Swift
Swift
33
star
27

AlamofireRACExtensions

ReactiveCocoa Swift extensions for Alamofire
Swift
32
star
28

Dial

The beginnings of a replacement Contacts app for iOS.
Objective-C
30
star
29

ReactiveBLE

ReactiveCocoa wrapper for communicating with BLE devices using CoreBluetooth
Objective-C
29
star
30

INSOCKSServer

SOCKS5 proxy server implementation in Objective-C
Objective-C
27
star
31

LiveWebPreview

Web development tool for automatically refreshing a page when the content changes.
Objective-C
20
star
32

SNRLastFMEngine

[DEPRECATED] A modern block-based Objective-C interface to the Last.fm API
Objective-C
19
star
33

AttributedString.swift

Swift library that adds type safety and string interpolation support to NSAttributedString
Swift
18
star
34

INKeychainAccess

[DEPRECATED] Objective-C Keychain Services Wrapper for OS X and iOS
Objective-C
17
star
35

tecs

Projects for The Elements of Computing Systems by Nisan and Schocken
Assembly
15
star
36

INTrafficLightsDisabler

SIMBL plugin to hide the traffic lights on Mac OS X
Objective-C
14
star
37

pebble-lifx

Pebble controller for LIFX bulbs. UAlberta CompE Club Hackathon 2014 project.
Objective-C
11
star
38

xcode-themes

Color themes for Xcode 4 and 5
6
star
39

radars

Apple Radars filed for OS X and iOS.
Objective-C
5
star
40

indragiek.github.com

http://indragie.com
HTML
3
star
41

arduino-copter

Copter game for Arduino + Adafruit TFT
C++
2
star
42

writing

Things that I write
2
star
43

advent-of-code-2020

My Rust solutions for https://adventofcode.com
Rust
1
star
44

bootstrap-no-responsive

Compiled Bootstrap with responsive features disabled
1
star