**Feature Request: Add “Object Explorer” Runtime Inspector**
**Background:**
DebugSwift offers extensive debugging utilities (console logs, network logs, resource explorers, etc.) but lacks a dedicated in-app object inspector. In contrast, [FLEX](https://github.com/FLEXTool/FLEX) provides a powerful Object Explorer that lets developers browse any live Objective-C object’s ivars, properties, methods, and more (see [FLEXObjectExplorerFactory.m](https://github.com/FLEXTool/FLEX/blob/master/Classes/ObjectExplorers/FLEXObjectExplorerFactory.m)) :contentReference[oaicite:21]{index=21}.
**Proposal:**
Introduce a new “Object Explorer” tab in the DebugSwift overlay. This feature should:
1. **List Live Instances** for a given class name or allow entering a specific object pointer/address for inspection.
2. **Display Sections** for:
- **Identity**: class name, memory address, isClassInstance.
- **Properties**: Swift and Obj-C properties using `Mirror` and `class_copyPropertyList`.
- **Ivars** (Obj-C only) via `class_copyIvarList`.
- **Methods**: selectors (Obj-C via `class_copyMethodList`) and Swift methods (via `Mirror`).
- **Associated Objects** using `objc_getAssociatedObject`.
- **View Hierarchy** for `UIView`/`UIViewController` types.
3. **Enable Editing** of writable properties (text fields, sliders, etc.) and **Method Invocation** (no-parameter methods at minimum).
4. **Follow DebugSwift’s UI Conventions**: Use `UITableViewController` with grouped sections, inline editors via `UIAlertController`, and navigation pushed onto the DebugSwift container’s navigation stack.
**Implementation Steps:**
1. Create `DSObjectExplorerSection` protocol (similar to `FLEXObjectExplorerSection`).
2. Implement `DSObjectExplorerViewController` (`UITableViewController`) that builds sections in `buildSections()`.
3. Add concrete sections (`DSIdentitySection.swift`, `DSPropertySection.swift`, etc.) by leveraging Swift’s `Mirror` and Objective-C runtime functions (see FLEX’s [FLEXIvarSection.m](https://github.com/FLEXTool/FLEX/blob/master/Classes/ObjectExplorers/Sections/FLEXIvarSection.m)) :contentReference[oaicite:22]{index=22}.
4. Register default “shortcuts” for UIKit classes—e.g., toggle `UIView.backgroundColor`—using a `DSShortcutsSection` modeled after [FLEXShortcutsSection.m](https://github.com/FLEXTool/FLEX/blob/master/Classes/ObjectExplorers/Sections/Shortcuts/FLEXShortcutsSection.m) :contentReference[oaicite:23]{index=23}.
5. Test thoroughly on both Swift-only classes (using `Mirror`) and mixed Obj-C/Swift classes (using a combination of runtime and reflection).
**References:**
- FLEX repo: [FLEXObjectExplorerFactory](https://github.com/FLEXTool/FLEX/blob/master/Classes/ObjectExplorers/FLEXObjectExplorerFactory.m) :contentReference[oaicite:24]{index=24}
- FLEX tutorial: “See the properties and ivars on any object” section in README (FLEX) :contentReference[oaicite:25]{index=25}
- Swift Mirror docs: [Apple Developer – Mirror](https://developer.apple.com/documentation/swift/mirror) :contentReference[oaicite:26]{index=26}
**Expected Outcome:**
After implementation, DebugSwift users can open the “Object Explorer” tab, enter a class name (e.g. `UIViewController`) or paste an object address, and interactively navigate through that object’s entire runtime surface (properties, ivars, methods, associated objects, view hierarchy). This will significantly speed up debugging workflows and bring DebugSwift’s capabilities closer to what FLEX offers for Objective-C apps.
Description
Summary
DebugSwift currently offers a rich set of debugging utilities (crash reports, network logs, view overlays, performance monitors, etc.) that make inspecting and interacting with an app much easier ([github.com]1, [github.com]2). However, it lacks a dedicated, in-app “Object Explorer” that lets developers browse any live Swift/Objective-C object’s properties, methods, ivars, and associated state at runtime ([github.com]3, [github.com]4). Adding this feature would greatly augment DebugSwift’s toolkit by giving real-time introspection similar to [FLEX](https://github.com/FLEXTool/FLEX) but tailored for Swift projects ([github.com]3, [github.com]5).
Motivation and Benefits
Deep Runtime Introspection
Enhanced Debugging Workflows
UIViewController) and modify values on the fly—similar to FLEX’s “edit property” or “invoke method” flows ([github.com]3, [github.com]6).Consistent UI/UX
Proposed Feature Overview
Object Explorer Entry Point
Add a new tab or menu item labeled “Object Explorer” inside the DebugSwift overlay UI (e.g. alongside “Console,” “Network Logs,” “User Defaults”) ([github.com]1, [github.com]2).
When tapped, present a search bar allowing the user to input either:
Top-Level Explorer Screen
Implement a
UITableViewController(e.g.DSObjectExplorerViewController) that displays the target object’s “sections,” such as:var/letand Objective-C@propertyvalues (using Mirror API for Swift andclass_copyPropertyListfor Obj-C).class_copyIvarList.class_copyMethodList) or Swift method names (viaMirrorcombined with the Swift runtime API).objc_getAssociatedObject).UIVieworUIViewController, show its subviews or child view controllers.Navigation & Editable Detail Screens
When a row is selected:
String,Int,NSObject *,UIView *), push a new explorer for the tapped value.Implementation Sketch
Reflection/Introspection Layer
Mirror(reflecting:)to enumerate children (label + value), filtering out private/internal props if desired ([github.com]3, [github.com]5).class_copyPropertyList,class_copyIvarList,class_copyMethodList) as demonstrated in FLEX’s [FLEXIvarSection](https://github.com/FLEXTool/FLEX/blob/master/Classes/ObjectExplorers/Sections/FLEXIvarSection.m) and [FLEXMethodSection](https://github.com/FLEXTool/FLEX/blob/master/Classes/ObjectExplorers/Sections/FLEXMethodSection.m) ([github.com]3, github.com).objc_getAssociatedObjectto list key/value pairs (FLEX does this in [FLEXAssociatedObjectsSection](https://github.com/FLEXTool/FLEX/blob/master/Classes/ObjectExplorers/Sections/FLEXAssociatedObjectsSection.m)) ([github.com]3, github.com).View Controller & UI Layer
Create
DSObjectExplorerSectionprotocol mirroringFLEXObjectExplorerSection(with methods:isAvailable(for:),numberOfRows(),title(),configure(cell:forRow:), anddidSelect(row:in:)) ([github.com]3, [github.com]4).Implement concrete sections:
DSIdentitySection(class name + address).DSPropertySection(Swift + Obj-C properties).DSIvarSection(Obj-C ivars only).DSMethodSection(selectors and simple Swift methods).DSAssociatedObjectsSection.DSViewHierarchySection.Bridging Swift & Obj-C
<objc/runtime.h>alongside Swift’s reflection utilities.@objcannotations, useMirroronly; for classes marked@objcMembersor inheriting fromNSObject, you can also use Objective-C runtime APIs.Registration & Defaults
UIView, print theview.frame, show the view’s constraints) ([github.com]3, [github.com]8).How to Get Started
Fork & Branch
feature/object-explorer. ([github.com]2)Create Protocol & Base Classes
DSObjectExplorerSection.swift(or.m/.hif you prefer Objective-C) to outline the section API.DSObjectExplorerViewController.swiftas a subclass ofUITableViewController, initializing with anyAnyobject and calling abuildSections()method.Implement Core Sections
DSIdentitySection. Usetype(of: obj)for the class name (Swift) orNSStringFromClass(object_getClass(obj))if it’s an Objective-C object ([github.com]3, [github.com]4).Mirror(reflecting:). For Obj-C, useclass_copyPropertyListandclass_copyIvarList.class_copyMethodListfor Obj-C. For Swift, enumerateMirror’s.childrenand filter for function types by testingMirror.Child’svaluewithtype(of:) is Function([github.com]3, [github.com]3).Navigation & Editors
didSelectRow(at:), determine the selected item’s type. If it’s a nested object (e.g. aUIViewwithin aUIViewController), instantiate a new explorer for that nested instance.String,Int,Bool), present anUIAlertControllerwith a text field to allow editing and then set the new value using Key-Value Coding (setValue(_:forKey:)for Obj-C) or by reconstructing the object in Swift (if it’s avar) ([github.com]3, [github.com]5).Testing & Examples
UILabelinstance) to ensure properties liketext,font,frameare displayed and editable.ViewModelstruct with properties) to verify thatMirrorintrospection works.view.layoutIfNeeded()) shows expected behavior.Implementation References
FLEXObjectExplorerSection([github.com]3, [github.com]6).class_copyIvarListandclass_copyPropertyListto enumerate runtime information ([github.com]3, [github.com]3).Mirrorto reflect Swift objects at runtime (e.g., see [Apple Developer – Mirror](https://developer.apple.com/documentation/swift/mirror)) ([github.com]3, [github.com]3).Example Issue Body
Citations
FLEXObjectExplorerFactory.mdemonstrating how to push an object explorer for any object ([github.com]5, [github.com]4)FLEXIvarSection.musingclass_copyIvarList([github.com]3, [github.com]3)class_copyMethodListinFLEXMethodSection([github.com]3, [github.com]3)FLEXShortcutsSection.mdemonstrating registration of class-specific actions ([github.com]3, [github.com]8)Mirrorreflection API for enumerating Swift object properties (Apple Developer – Mirror) ([github.com]3, [github.com]3)FLEXAssociatedObjectsSection.mshowing how to list associated objects at runtime ([github.com]3, [github.com]3)