DebugSwift / DebugSwift
- ΡΡΠ±Π±ΠΎΡΠ°, 14 ΡΠ΅Π²ΡΠ°Π»Ρ 2026β―Π³. Π² 00:00:05
A toolkit to make debugging iOS applications easier π
Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/DebugSwift/DebugSwift.git", from: "2.0.0")
]Or add through Xcode: File > Add Package Dependencies > Enter URL:
https://github.com/DebugSwift/DebugSwift
Add to your Podfile:
pod 'DebugSwift'Add to your Podfile:
pod 'DebugSwift', :http => 'https://github.com/DebugSwift/DebugSwift/releases/latest/download/DebugSwift.xcframework.zip'DebugSwift fully supports Apple Silicon Macs with native arm64 simulator builds! No more architecture exclusions or compatibility issues.
Supported Architectures:
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.
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
}
}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
}
}If you encounter build errors like error unsupported Swift architecture or DebugSwift.framework only contains x86_64 slice for simulator on Apple Silicon Macs:
Ensure you're using the latest version of DebugSwift which includes full Apple Silicon support:
# CocoaPods
pod 'DebugSwift', '~> 1.8.1'
# Swift Package Manager - update to latestFor faster builds and guaranteed architecture compatibility:
pod 'DebugSwift', :http => 'https://github.com/DebugSwift/DebugSwift/releases/latest/download/DebugSwift.xcframework.zip'If you have custom architecture exclusions in your project, remove them:
# Remove this from your Podfile or target configuration:
# config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'Clean your build folder and derived data:
# Xcode
Product β Clean Build Folder (ββ§K)
# Command line
rm -rf ~/Library/Developer/Xcode/DerivedDataChoose XCFramework for production builds, source for active development.
Harness the Power of Visual Information within the iOS Hierarchy Tree to Uncover Intricate Layouts and Element Relationships in Your Application.
Simply press and hold the circle button to reveal the Snapshot and Hierarchy for a comprehensive overview.
Enhance your understanding by pressing and holding on a specific view to reveal information such as:
DebugSwift.App.shared.customControllers = {
let controller1 = UITableViewController()
controller1.title = "Custom TableVC 1"
let controller2 = UITableViewController()
controller2.title = "Custom TableVC 2"
return [controller1, controller2]
}// Add custom debugging actions
DebugSwift.App.shared.customAction = {
[
.init(title: "Development Tools", actions: [
.init(title: "Clear User Data") {
UserDefaults.standard.removeObject(forKey: "userData")
},
.init(title: "Reset App State") {
// Your reset logic here
}
])
]
}DebugSwift.App.shared.customInfo = {
[
.init(
title: "Info 1",
infos: [
.init(title: "title 1", subtitle: "title 2")
]
)
]
}// In your AppDelegate
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
DebugSwift.APNSToken.didRegister(deviceToken: deviceToken)
// Your existing token handling code
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
DebugSwift.APNSToken.didFailToRegister(error: error)
// Your existing error handling code
}// Ignore specific URLs
DebugSwift.Network.shared.ignoredURLs = ["https://analytics.com"]
// Monitor only specific URLs
DebugSwift.Network.shared.onlyURLs = ["https://api.myapp.com"]// Clear HTTP/HTTPS request history (useful when switching environments)
DebugSwift.Network.shared.clearNetworkHistory()
// Clear WebSocket connection history
await DebugSwift.Network.shared.clearWebSocketHistory()
// Clear all network data (HTTP + WebSocket)
await DebugSwift.Network.shared.clearAllNetworkData()
// Example: Clear network data when switching environments
DebugSwift.App.shared.customAction = {
[
.init(title: "Environment", actions: [
.init(title: "Switch to Production") {
// Your environment switch logic
DebugSwift.Network.shared.clearNetworkHistory()
},
.init(title: "Switch to Development") {
// Your environment switch logic
DebugSwift.Network.shared.clearNetworkHistory()
}
])
]
}If you create URLSessionConfiguration instances before calling DebugSwift.setup(), you can manually inject the network monitoring protocol:
// Option 1: Inject into existing configuration
let config = URLSessionConfiguration.default
DebugSwift.Network.shared.injectIntoConfiguration(config)
let session = URLSession(configuration: config)
// Option 2: Get pre-configured default configuration
let config = DebugSwift.Network.shared.defaultConfiguration()
let session = URLSession(configuration: config)
// Option 3: Get pre-configured ephemeral configuration
let config = DebugSwift.Network.shared.ephemeralConfiguration()
let session = URLSession(configuration: config)
// Option 4: Direct protocol class injection (advanced)
var config = URLSessionConfiguration.default
var protocolClasses = config.protocolClasses ?? []
protocolClasses.insert(CustomHTTPProtocol.self, at: 0)
config.protocolClasses = protocolClassesNote: This is particularly useful when migrating from other network debugging tools like Netfox or when working with pre-existing URLSession configurations.
DebugSwift supports automatic decryption of encrypted API responses, making it easier to debug apps with end-to-end encryption.
// Enable decryption feature
DebugSwift.Network.shared.setDecryptionEnabled(true)
// Register decryption key for specific API endpoints
if let key = "your-32-byte-aes-key-here-123456".data(using: .utf8) {
DebugSwift.Network.shared.registerDecryptionKey(for: "api.example.com", key: key)
}
// Register custom decryptor for complex encryption schemes
DebugSwift.Network.shared.registerCustomDecryptor(for: "api.myapp.com") { encryptedData in
// Your custom decryption logic here
return customDecrypt(encryptedData)
}debugSwift.setup(
hideFeatures: [.performance, .interface], // Hide specific tabs
disable: [.leaksDetector, .console] // Disable specific monitoring
)// Enable beta features (disabled by default)
debugSwift.setup(
enableBetaFeatures: [.swiftUIRenderTracking] // Enable experimental SwiftUI render tracking
)// Configure app groups for file browser access
DebugSwift.Resources.shared.configureAppGroups([
"group.com.yourcompany.yourapp"
])// Configure memory leak detection
DebugSwift.Performance.shared.onLeakDetected { leakData in
print("π΄ Memory leak detected: \(leakData.message)")
}// Enable push notification simulation
DebugSwift.PushNotification.enableSimulation()
// Simulate a notification
DebugSwift.PushNotification.simulate(
title: "Test Notification",
body: "This is a test notification"
)// First enable the beta feature in setup
debugSwift.setup(enableBetaFeatures: [.swiftUIRenderTracking])
// Then enable SwiftUI render tracking
DebugSwift.SwiftUIRender.shared.isEnabled = true
// Configure persistent overlays (stay visible until manually cleared)
DebugSwift.SwiftUIRender.shared.persistentOverlays = true
// Set overlay style (border, borderWithCount, none)
DebugSwift.SwiftUIRender.shared.overlayStyle = .borderWithCount
// Configure overlay duration
DebugSwift.SwiftUIRender.shared.overlayDuration = 1.0
// Enable console logging
DebugSwift.SwiftUIRender.shared.loggingEnabled = true
// Clear render statistics
DebugSwift.SwiftUIRender.shared.clearStats()
// Clear persistent overlays
DebugSwift.SwiftUIRender.shared.clearPersistentOverlays()If you find DebugSwift helpful, please consider giving us a star on GitHub! Your support helps us continue improving and adding new features.
Our contributors have made this project possible. Thank you!
Contributions are welcome! If you have suggestions, improvements, or bug fixes, please submit a pull request. Let's make DebugSwift even more powerful together!
DebugSwift is licensed under the MIT License - see the LICENSE file for details.