Skip to content

lynnswap/WebInspectorKit

Repository files navigation

WebInspectorKit

WebInspectorKit preview

UIKit Web Inspector for WKWebView.

Warning

This package relies on undocumented APIs and runtime behavior, so extra care is needed before using it in App Store-bound projects.

Features

  • DOM tree browsing with native UIKit/TextKit2 presentation
  • Network request logging with native list/detail presentation
  • Built-in DOM and Network tabs
  • Explicit lifecycle via WebInspectorSession / WebInspectorViewController (attach(to:), detach())
  • Observation-backed WebInspector model state

Requirements

  • Swift 6.2+
  • iOS 18+
  • WKWebView with JavaScript enabled

Platform Notes

  • The current implementation targets UIKit on iOS.
  • AppKit support is planned to be rebuilt separately.

Quick Start

UIKit

import UIKit
import WebKit
import WebInspectorKit

final class BrowserViewController: UIViewController {
    private let pageWebView = WKWebView(frame: .zero)

    @objc private func presentInspector() {
        let inspector = WebInspectorViewController()
        inspector.modalPresentationStyle = .pageSheet
        if let sheet = inspector.sheetPresentationController {
            sheet.detents = [.medium(), .large()]
            sheet.selectedDetentIdentifier = .medium
        }
        Task { @MainActor in
            try await inspector.attach(to: pageWebView)
            present(inspector, animated: true)
        }
    }
}

Tabs

let inspector = WebInspectorViewController(
    tabs: [.dom, .network]
)

The current public tab surface exposes the built-in DOM and Network tabs.

Documentation

Start with MIGRATION.md when updating from an older release.

For implementation work, ArchitectureOverview.md is the top-level map for module boundaries, runtime ownership, and transport flow. Core-specific model notes are rooted at the WebInspectorCore README, which links to the detailed DOM, CSS, Network, and transport research docs kept next to the Core target.

License

See LICENSE.

About

Web Inspector for WKWebView on iOS

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors