A visual developer tool for inspecting your iOS application data structures.

Overview

Tree Dump Debugger

A visual developer tool for inspecting your iOS application data structures.

drawing drawing drawing

Features

Inspect any data structure with only one line of code:

TreeDumpDebugger.present(["foo": "bar", 122: [122, 45, 4]])

Or from a SwiftUI view:

Button("Press me") {
    showSwiftUIModal = true
}.sheet(isPresented: $showSwiftUIModal) {
    TreeDumpDebugger.makeSwiftUIView(with: ["foo": "bar", 122: [122, 45, 4]])
}

You can modify any node in the tree, can be useful if you want different formatting or hide sensitive data:

struct TestB {
    var number: Int
}
class TestA {
    init(myProperty: String, b: TestB) {
        self.myProperty = myProperty
        self.b = b
    }
    var myProperty: String
    let b: TestB
}

let data = TestA(myProperty: "This is a string", b: TestB(number: 122))

TreeDumpDebugger.present(data) { string in
    if let range = string.range(of: "This is a string") {
        return string.replacingCharacters(in: range, with: "Still a string but changed")
    }
    return string
}

TreeDumpDebugger.present(data) { string in
    return string.replacingOccurrences(of: "", with: "😎")
}

How does it work?

Tree Dump Debugger parses indented output into a tree structure. It uses Swift's built dump function by default. No private APIs are used.

If you want to use another dumping tool it’s possible to do so by conforming to the TreeDumpRepresentable protocol.

public protocol TreeDumpRepresentable {
    func makeLine(string: String, lineOutput: (String) -> Void)
    func dump(using tree: inout TreeDumpDebugger.Tree)
}

So if we for instance would like to use swift-custom-dump which is another great dumping tool:

import CustomDump

struct CustomDump<T>: TreeDumpRepresentable {
    let value: T
    var name: String? = nil
    var indent: Int = 0
    var maxDepth: Int = .max

    func makeLine(string: String, lineOutput: (String) -> Void) {
        let lines = string.components(separatedBy: .newlines)
        for line in lines {
            lineOutput(line)
        }
    }

    func dump(using tree: inout TreeDumpDebugger.Tree) {
        customDump(value, to: &tree, name: name, indent: indent, maxDepth: maxDepth)
    }

}

TreeDumpDebugger.present(CustomDump(value: data))

Installation

Simply drag and drop TreeDumpDebugger.swift into your project. Since this a debugging tool it’s probably a good idea to wrap the whole file in a #if DEBUG.

Why no Swift Package?

There is currently no support to conditionally embed a framework in Package.swift for a debug configuration, so a Swift Package would probably just do more harm than good.

Requirements

iOS 14

Other ways of using it

The repo also contains a LLDB script that can used to present the debugger view on the fly.

(lldb) tdump ["foo", "bar", 122, 3223]

drawing

To use the script add this line to your .lldbinit

command script import <path/to/script>

Or use lowmad

$ lowmad install https://github.com/bangerang/tree-dump-debugger.git
You might also like...
qr code generator tool

qr code generator tool Small command line tool for generate and reconition qr codes written in Swift Using Usage: ./qrgen [options] -m, --mode:

AnalyticsKit for Swift is designed to combine various analytical services into one simple tool.

🦋 AnalyticsKit AnalyticsKit for Swift is designed to combine various analytical services into one simple tool. To send information about a custom eve

SwiftRegressor - A linear regression tool that’s flexible and easy to use

SwiftRegressor - A linear regression tool that’s flexible and easy to use

BudouX: the machine learning powered line break organizer tool
BudouX: the machine learning powered line break organizer tool

BudouX.swift BudouX Swift implementation. BudouX is the machine learning powered

A little beautifier tool for xcodebuild

xcbeautify xcbeautify is a little beautifier tool for xcodebuild. Similar to xcpretty, but faster. Features 2x faster than xcpretty. Human-friendly an

Scaffold is a tool for generating code from Stencil templates, similar to rails gen.

🏭 Scaffold Scaffold is a tool for generating code from Stencil templates, similar to rails gen. It happens to be written in Swift, but it can output

A reverse engineering tool to restore stripped symbol table and dump Objective-C class or Swift types for machO file.

A reverse engineering tool to restore stripped symbol table and dump Objective-C class or Swift types for machO file.

Swift library and command line tool that interacts with the mach-o file format.
Swift library and command line tool that interacts with the mach-o file format.

MachO-Reader Playground project to learn more about the Mach-O file format. How to run swift run MachO-Reader path-to-binary You should see a simila

🚘 A simple tool for updating Carthage script phase
🚘 A simple tool for updating Carthage script phase

Do you use Carthage? Are you feel tired of adding special script and the paths to frameworks (point 4, 5 and 6 in Getting Started guide) manually? Me

Releases(v0.1.0)
Owner
Add a bio.
null
Swift-DocC is a documentation compiler for Swift frameworks and packages aimed at making it easy to write and publish great developer documentation.

Swift-DocC is a documentation compiler for Swift frameworks and packages aimed at making it easy to write and publish great developer docum

Apple 833 Jan 3, 2023
A tool to convert Apple PencilKit data to Scribble Proto3.

ScribbleConverter Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation

Paul Han 1 Aug 1, 2022
Framework for easily parsing your JSON data directly to Swift object.

Server sends the all JSON data in black and white format i.e. its all strings & we make hard efforts to typecast them into their respective datatypes

Mukesh 11 Oct 17, 2022
LifetimeTracker can surface retain cycle / memory issues right as you develop your application

LifetimeTracker Bar style Circular style LifetimeTracker can surface retain cycle / memory issues right as you develop your application, and it will s

Krzysztof Zabłocki 2.8k Jan 4, 2023
The simplest way to display the librarie's licences used in your application.

Features • Usage • Translation • Customisation • Installation • License Display a screen with all licences used in your application can be painful to

Florian Gabach 51 Feb 28, 2022
Differific is a diffing tool that helps you compare Hashable objects using the Paul Heckel's diffing algorithm

Differific is a diffing tool that helps you compare Hashable objects using the Paul Heckel's diffing algorithm. Creating a chan

Christoffer Winterkvist 127 Jun 3, 2022
A functional tool-belt for Swift Language similar to Lo-Dash or Underscore.js in Javascript

Dollar Dollar is a Swift library that provides useful functional programming helper methods without extending any built in objects. It is similar to L

Ankur Patel 4.2k Jan 2, 2023
A command-line tool and Swift Package for generating class diagrams powered by PlantUML

SwiftPlantUML Generate UML class diagrams from swift code with this Command Line Interface (CLI) and Swift Package. Use one or more Swift files as inp

null 374 Jan 3, 2023
A SARS-CoV-2 Mutation Pattern Query Tool

vdb A SARS-CoV-2 Mutation Pattern Query Tool 1. Purpose The vdb program is designed to query the SARS-CoV-2 mutational landscape. It runs as a command

null 13 Oct 25, 2022
This package will contain the standard encodings/decodings/hahsing used by the String Conversion Tool app.

This package will contain the standard encodings/decodings/hahsing used by the String Conversion Tool app. It will also, however, contain extra encoding/decoding methods (new encoding/decoding)

Gleb 0 Oct 16, 2021