|
4 | 4 | [](https://github.com/Carthage/Carthage) |
5 | 5 |
|
6 | 6 | <p align="center"> |
7 | | -<img alt="InAppViewDebugger" src="images/main.png" width="100%" max-width="800"> |
| 7 | +<img alt="InAppViewDebugger" src="images/main.png" width="700"> |
| 8 | +</p> |
| 9 | + |
| 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 | + |
| 12 | +### Features |
| 13 | + |
| 14 | +* **3D snapshot view implemented in SceneKit**: Gesture controls zooming, panning, and rotating |
| 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 | +* **Support for iPad and iPhone**: Layouts are designed specifically for each form factor. |
| 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) |
| 18 | + |
| 19 | +### Requirements |
| 20 | + |
| 21 | +* iOS 11.0+ |
| 22 | +* Xcode 10.1+ (framework built for Swift 4.2) |
| 23 | + |
| 24 | +### Installation |
| 25 | + |
| 26 | +#### CocoaPods |
| 27 | + |
| 28 | +Add the following line to your `Podfile`: |
| 29 | + |
| 30 | +``` |
| 31 | +pod 'InAppViewDebugger', '~> 1.0.0' |
| 32 | +``` |
| 33 | + |
| 34 | +#### Carthage |
| 35 | + |
| 36 | +Add the following line to your `Cartfile`: |
| 37 | + |
| 38 | +``` |
| 39 | +github "indragiek/InAppViewDebugger" "1.0.0" |
| 40 | +``` |
| 41 | + |
| 42 | +### Usage |
| 43 | + |
| 44 | +#### Swift |
| 45 | + |
| 46 | +From code: |
| 47 | + |
| 48 | +```swift |
| 49 | +import InAppViewDebugger |
| 50 | + |
| 51 | +@IBAction func showViewDebugger(sender: AnyObject) { |
| 52 | + InAppViewDebugger.present() |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +From `lldb`: |
| 57 | + |
| 58 | +``` |
| 59 | +(lldb) e -lswift -- import InAppViewDebugger |
| 60 | +(lldb) e -lswift -- InAppViewDebugger.present() |
| 61 | +``` |
| 62 | + |
| 63 | +#### Objective-C |
| 64 | + |
| 65 | +```objc |
| 66 | +#import <InAppViewDebugger/InAppViewDebugger-Swift.h> |
| 67 | + |
| 68 | +- (IBAction)showViewDebugger:(id)sender { |
| 69 | + [InAppViewDebugger present]; |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +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 | + |
| 75 | +### Controls |
| 76 | + |
| 77 | +#### Adjusting Distance Between Levels |
| 78 | + |
| 79 | +The slider on the bottom left of the snapshot view can be used to adjust the spacing between levels of the hierarchy: |
| 80 | + |
| 81 | +<p align="center"> |
| 82 | +<img alt="InAppViewDebugger" src="images/distance.gif" width="700"> |
8 | 83 | </p> |
0 commit comments