You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-17Lines changed: 43 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,41 +9,41 @@
9
9
10
10
`InAppViewDebugger` is a library that implements a view debugger with a 3D snapshot view and a hierarchy view, similar to [Reveal](https://revealapp.com) and [Xcode's own view debugger](https://developer.apple.com/library/archive/documentation/ToolsLanguages/Conceptual/Xcode_Overview/ExaminingtheViewHierarchy.html). 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.
11
11
12
-
###Features
12
+
## Features
13
13
14
14
***3D snapshot view implemented in SceneKit**: Gesture controls for zooming, panning, and rotating.
15
15
***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
16
16
***Support for [iPad](images/main.png) and [iPhone](images/iphone1.png)**: Layouts are designed specifically for each form factor.
17
17
***Extensible:** The base implementation supports `UIView` hierarchies, but this is easily extensible to support any kind of UI framework (e.g. CoreAnimation or SpriteKit)
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.
74
74
75
-
###Controls
75
+
## Controls
76
76
77
-
####Focusing on an Element
77
+
### Focusing on an Element
78
78
79
-
To focus on the subhierarchy of a particular element, **long press on the element** to bring up the action menu and tap "Focus". 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.
79
+
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.
80
80
81
81
<palign="center">
82
82
<imgalt="Focusing on an Element"src="images/focus.gif"width="700">
83
83
</p>
84
84
85
-
####Adjusting Distance Between Levels
85
+
### Adjusting Distance Between Levels
86
86
87
87
The slider on the bottom left of the snapshot view can be used to adjust the spacing between levels of the hierarchy:
88
88
89
89
<palign="center">
90
90
<imgalt="Adjusting Distance Between Levels"src="images/distance.gif"width="700">
91
91
</p>
92
92
93
-
####Adjusting Visible Levels
93
+
### Adjusting Visible Levels
94
94
95
95
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:
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:
Colors, fonts, and other attributes for both the snapshot view and the hierarchy view can be changed by creating a custom [`Configuration`](blob/master/InAppViewDebugger/Configuration.swift). The configuration is then passed to a function like `InAppViewDebugger.presentForWindow(:configuration:completion:)`.
120
+
121
+
## Extending for Other UI Frameworks
122
+
123
+
The current implementation only supports `UIView` hierarchies, but this can easily be extended to support other UI frameworks by conforming to the [`Element`](blob/master/InAppViewDebugger/Element.swift) protocol. See [`ViewElement`](blob/master/InAppViewDebugger/ViewElement.swift) 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.
124
+
125
+
A [`Snapshot`](blob/master/InAppViewDebugger/Snapshot.swift) 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.
126
+
127
+
## Credits
128
+
129
+
*[Kyle Van Essen](https://twitter.com/kyleve) for [this tweet](https://twitter.com/kyleve/status/1111689823759171585) picturing Square's implementation that inspired me to build this
130
+
*[AudioKit SynthOne](https://github.com/AudioKit/AudioKitSynthOne), an amazing open-source audio synthesizer app for the iPad that made for a great demo as pictured above
131
+
132
+
## Contact
133
+
134
+
* Indragie Karunaratne
135
+
*[@indragie](http://twitter.com/indragie)
136
+
*[http://indragie.com](http://indragie.com)
137
+
138
+
## License
139
+
140
+
`InAppViewDebugger` is licensed under the MIT License. See `LICENSE` for more information.
0 commit comments