This package can help you (or testers/QA/TM in your team) to do on-device debugging with easy. It can show PiP-style console that can display any meaningful info that you need. Also you can add custom actions to the console menu, for facilitating some useful routine for testing (to copy push/fcm token for example).
This project was inspared by LocalConsole from Duraid Abdul. But it supports only iOS 14+, you can't add your actions, but can dynamically display view frames and restart SpringBoard. This project supports iOS 11+.
-
In your Xcode project, navigate to File > Swift Packages > Add Package Dependency...
-
Paste the following into the URL field: https://github.com/Dalein/GIAppDebugConsole.git
-
Once the package dependency has been added, you can import GIAppDebugConsole.
To show console you can call it from anywhere:
GIAppDebugConsole.shared.show()
To log something:
GIAppDebugConsole.shared.log("test")
Or attributed string:
GIAppDebugConsole.shared.logAttributed(.init(string: "My super log", attributes: [.foregroundColor: UIColor.red]))
It's safe to log simultaneously string and NSAttributedString.
By default console has two actions in menu: Clear console and Copy. You can add your own actions like this:
GIAppDebugConsole.shared.addAction(.init(title: "Copy Push token", handler: { [weak self] in
self?.copyPushToken()
}))
GIAppDebugConsole.shared.addAction(.init(title: "Do a barrel roll", handler: { [weak self] in
self?.doBarrelRoll()
}))
Console is fully customazible, you can setup it UI as you wish. You can adjust all, or only interesting you settings (all has default values). Call it before first console show. Fully setup can look like this:
GIAppDebugConsoleConfigurator.configureAppDebugConsole(
consoleUIConfig: .init(consoleDefaultSize: .init(width: 300, height: 200),
consoleMaxSize: .init(width: 500, height: 500),
consoleBackgroundColor: .red,
textColor: .white,
font: .systemFont(ofSize: 20, weight: .bold),
menuButtonConfig: .init(size: .init(width: 50, height: 50),
backgroundColor: .black,
image: .init(named: "ellipsis"),
title: nil,
tintColor: .blue, alpha: 0.7)))
Example project can be found here.