schwarzit/swift-network-debugger
---
Features
- Minimal setup. Add one line of code and the package does the rest!
- Built-in shake gestures that can be disabled!
- SwiftUI and UIKit compatible!
- Ignore hosts from being recorded!
- Use settings at runtime to filter the requests!
- Syntax highlighting for body data!
Installation
Swift Package Manager
Install through the Swift Package Manager using Xcode.
Setup
In order for the package to work properly, you need to call start() as the first method in your AppDelegate! (For SwiftUI apps you need to use @UIApplicationDelegateAdaptor) Note: It is highly encouraged to only call start() in debug or testing environments and not in production.
final class ApplicationDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
#if DEBUG
NetworkDebugger.start()
#endif
}
}Configuration
All configuration has to be called before the start() method is called.
Ignoring hosts
Simply set the ignoredHosts property!
NetworkDebugger.ignoredHosts = [
"subdomain.example.com",
"example.com"
]Limiting amount of requests
NetworkDebugger only stores n amount of requests. You can configure this by setting the maxRequests property!
NetworkDebugger.maxRequests = 100 // DefaultDisabling shake gestures
To disable shake gestures simply set the shakeEnabled property!
NetworkDebugger.shakeEnabled = falseDisplaying NetworkDebugger
SwiftUI
For SwiftUI, simply return the NetworkDebuggerView()!
struct MyView: View {
var body: some View {
NetworkDebuggerView()
}
}UIKit
For UIKit, simply call presentNetworkDebugger()! Optionally you can provide the UIViewController to present NetworkDebugger on.
class MyViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// If the ViewController is known
NetworkDebugger.presentNetworkDebugger(on: self)
// Will attempt to display on the top most ViewController
NetworkDebugger.presentNetworkDebugger()
}
}Maintainers
| Name | Email | | :------------------------------------- | :------------------------- | | @Asmeili | michael.artes@mail.schwarz |
Package Metadata
Repository: schwarzit/swift-network-debugger
Default branch: main
README: README.md