DebugSwift
DebugSwift is a comprehensive toolkit designed to streamline and elevate the debugging experience for Swift-based applications. Whether you are troubleshooting issues or optimizing performance, DebugSwift offers a powerful set of features to make your debugging process more efficient and effective. |
|
๐ Table of Contents
Requirements
- iOS 14.0+
- Swift 6.0+
- Xcode 16.0+
Features
๐ Network Inspector
- HTTP Monitoring: Capture all requests/responses with detailed logs and filtering
- WebSocket Inspector: Zero-config automatic monitoring of WebSocket connections and frames
- Request Limiting: Set thresholds to monitor and control API usage
- Smart Content: Automatic JSON formatting with syntax highlighting
- Encryption Support: Automatic decryption of encrypted API responses with AES-256/128 and custom decryptors
- Response Modifier: Mock or modify any API responses in real time. Adjust the response body and status based on URL or patterns, enable or disable rules individually, import/export configurations via CSV, body editor, and generate rules from live network traffic.
โก Performance
- Real-time Metrics: Monitor CPU, memory, and FPS in real-time
- Memory Leak Detection: Automatic detection of leaked ViewControllers and Views
- Thread Checker: Detect main thread violations with detailed stack traces
- Performance Widget: Overlay displaying live performance stats
๐ฑ App Tools
- Crash Reports: Detailed crash analysis with screenshots and stack traces
- Console Logs: Real-time console output monitoring and filtering
- Device Info: App version, build, device details, and more
- APNS Tokens: Easy access and copying of push notification tokens
- Custom Actions: Add your own debugging actions and info
๐จ Interface Tools
- Grid Overlay: Visual alignment grid with customizable colors and opacity
- View Hierarchy: 3D interactive view hierarchy inspector
- Touch Indicators: Visual feedback for touch interactions
- Animation Control: Slow down animations for easier debugging
- View Borders: Highlight view boundaries with colorization
- SwiftUI Render Tracking (Beta): Automatically detect and visualize SwiftUI view re-renders with dedicated settings screen
- Documentation Recorder: Record app interactions with annotated screenshots โ taps shown as numbered circles, scrolls as arrows. Save, copy as grid, or share recordings
๐ Resources
- File Browser: Navigate app sandbox and shared app group containers
- UserDefaults: View and modify app preferences at runtime
- Keychain: Inspect keychain entries
- Database Browser: SQLite and Realm database inspection
- Push Notifications: Simulate push notifications with templates and test scenarios
- SwiftData Browser (iOS 17+): Inspect registered SwiftData containers, browse models, inspect properties/relationships, edit values, and export JSON
Installation & Setup
๐ Swift Package Manager (Recommended)
Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/DebugSwift/DebugSwift.git", from: "1.0.0")
]
Or add through Xcode: File > Add Package Dependencies > Enter URL:
https://github.com/DebugSwift/DebugSwift
๐ฏ CocoaPods
Option 1: Source Distribution (Standard)
Add to your Podfile:
pod 'DebugSwift'
Option 2: XCFramework Distribution (Faster Builds) โก
Add to your Podfile:
pod 'DebugSwift', :http => 'https://github.com/DebugSwift/DebugSwift/releases/latest/download/DebugSwift.xcframework.zip'
๐ Apple Silicon Support
DebugSwift fully supports Apple Silicon Macs with native arm64 simulator builds! No more architecture exclusions or compatibility issues.
Supported Architectures:
- ๐ฑ iOS Device: arm64
- ๐ฅ๏ธ iOS Simulator: arm64 (Apple Silicon) + x86_64 (Intel)
Migration Note: If you were using architecture exclusions like 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64', you can now remove them as they are no longer needed.
Basic Setup
import DebugSwift
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
private let debugSwift = DebugSwift()
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
#if DEBUG
debugSwift.setup()
// debugSwift.setup(disable: [.leaksDetector])
debugSwift.show()
#endif
return true
}
}
Shake to Toggle (Optional)
extension UIWindow {
open override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
super.motionEnded(motion, with: event)
#if DEBUG
if motion == .motionShake {
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
appDelegate.debugSwift.toggle()
}
}
#endif
}
}
Open Debugger Programmatically
You can get the debug menu as a standalone UIViewController and present it however you like โ push, present modally, embed in your own navigation. No floating ball required.
// 1. Setup (without floating ball)
#if DEBUG
DebugSwift().setup()
// Don't call .show() โ no floating ball will appear
#endif
// 2. Get the debug view controller and present it yourself
let debugVC = DebugSwift.debugViewController()
// Push into your navigation stack
navigationController?.pushViewController(debugVC, animated: true)
// Or present modally
let nav = UINavigationController(rootViewController: debugVC)
present(nav, animated: true)
SwiftUI
Wrap in a UINavigationController so the close button and dark nav bar match the FloatingView experience:
struct DebugViewControllerRepresentable: UIViewControllerRepresentable {
let onDismiss: () -> Void
func makeUIViewController(context: Context) -> UINavigationController {
let debugVC = DebugSwift.debugViewController()
let closeButton = UIBarButtonItem(
image: UIImage(systemName: "xmark"),
style: .plain, target: context.coordinator,
action: #selector(Coordinator.close)
)
closeButton.tintColor = .white
debugVC.navigationItem.rightBarButtonItem = closeButton
let nav = UINavigationController(rootViewController: debugVC)
let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
appearance.backgroundColor = .black
nav.navigationBar.standardAppearance = appearance
nav.navigationBar.scrollEdgeAppearance = appearance
nav.navigationBar.compactAppearance = appearance
nav.overrideUserInterfaceStyle = .dark
return nav