A toolkit to make debugging iOS applications easier š
DebugSwift is a comprehensive toolkit designed to simplify and enhance the debugging process for Swift-based applications. Whether youāre troubleshooting issues or optimizing performance, DebugSwift provides a set of powerful features to make your debugging experience more efficient. |
---|
Add the following line to your Podfile
:
pod 'DebugSwift', :git => 'https://github.com/DebugSwift/DebugSwift.git', :branch => 'main'
Then, run:
pod install
Add the following dependency to your Package.swift
file:
.package(url: "https://github.com/DebugSwift/DebugSwift.git", from: "main")
Then, add "DebugSwift"
to your targetās dependencies.
func application(
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
DebugSwift.setup()
DebugSwift.show()
return true
}
extension UIWindow {
open override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
super.motionEnded(motion, with: event)
if motion == .motionShake {
DebugSwift.toggle()
}
}
}
If you want to ignore specific URLs, use the following code:
DebugSwift.Network.ignoredURLs = ["https://reqres.in/api/users/23"]
If you want to capture only a specific URL, use the following code:
DebugSwift.Network.onlyURLs = ["https://reqres.in/api/users/23"]
Adjust the URLs in the arrays according to your needs.
DebugSwift.App.customInfo = {
[
.init(
title: "Info 1",
infos: [
.init(title: "title 1", subtitle: "title 2")
]
)
]
}
DebugSwift.App.customAction = {
[
.init(
title: "Action 1",
actions: [
.init(title: "action 1") { [weak self] in // Important if use self
print("Action 1")
}
]
)
]
}
DebugSwift.App.customControllers = {
let controller1 = UITableViewController()
controller1.title = "Custom TableVC 1"
let controller2 = UITableViewController()
controller2.title = "Custom TableVC 2"
return [controller1, controller2]
}
If you prefer to selectively disable certain features, DebugSwift can now deactivate unnecessary functionalities. This can assist you in development across various environments.
func application(
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
DebugSwift.setup(
// Main features
hideFeatures: [
.network,
.resources,
.performance,
.interface,
.app
],
// Swizzle features
disable: [
.network,
.location,
.views,
.crashManager,
.leaksDetector,
.console
]
)
DebugSwift.show()
return true
}
Get the data from memory leaks in the app.
DebugSwift.Performance.LeakDetector.onDetect { data in
// If you want to send data to some analytics
print(data.message) // Retuns the name of the class and the error
print(data.controller) // If is an controller leak
print(data.view) // If is an view leak
print(data.isDeallocation) // If is an deallocation of leak (good for false/positive)
}
Dynamic Theme: Easily Change the Interface Appearance from Dark to Light, Customize According to Your Needs.
func application(
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
DebugSwift.theme(appearance: .light)
DebugSwift.setup()
DebugSwift.show()
return true
}
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:
uploadProgress
In the AppDelegate
.
class AppDelegate {
func application(
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
DebugSwift.setup()
DebugSwift.show()
// Call this method
DebugSwift.Network.delegate = self
return true
}
}
And conform with the protocol:
extension AppDelegate: CustomHTTPProtocolDelegate {
func urlSession(
_ protocol: URLProtocol,
_ session: URLSession,
task: URLSessionTask,
didSendBodyData bytesSent: Int64,
totalBytesSent: Int64,
totalBytesExpectedToSend: Int64
) {
Session.default.session.getAllTasks { tasks in
let uploadTask = tasks.first(where: { $0.taskIdentifier == task.taskIdentifier }) ?? task
Session.default.rootQueue.async {
Session.default.delegate.urlSession(
session,
task: uploadTask,
didSendBodyData: bytesSent,
totalBytesSent: totalBytesSent,
totalBytesExpectedToSend: totalBytesExpectedToSend
)
}
}
}
}
Thank you for visiting our project! If you find our work helpful and would like to support us, please consider giving us a ā star on GitHub. Your support is crucial for us to continue improving and adding new features.
Every star counts and makes a difference. Thank you for your support! š
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.