可自定义的控制台 UI 覆盖层,在您的 iOS 应用顶部显示调试日志
AEConsole 构建于 AELog 之上,因此您可能应该先了解一下它。
我希望在测试一些 AFK(例如,在户外)应用时,能够看到“幕后”发生了什么。然后我使其成为可能。希望您也会喜欢它,祝您编码愉快!
调用 Console.shared.configure(in: window)
将 Console.View
添加为您的应用窗口的子视图,并默认将其隐藏。当您需要控制台 UI 时,只需摇动手机,它就会出现!当您不再需要它时,再次摇动手机,它就会消失。
其余功能由 AELog 的日志记录功能决定。使用它记录的任何内容都将显示在 Console.View
中。
// MARK: - Console configuration
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
{
/// - Note: Access Console settings
let settings = Console.shared.settings
/// - Note: Customize Console settings like this, these are defaults:
settings.isShakeGestureEnabled = true
settings.backColor = UIColor.black
settings.textColor = UIColor.white
settings.fontSize = 12.0
settings.rowSpacing = 4.0
settings.opacity = 0.7
/// - Note: Configure Console in app window (it's recommended to skip this for public release)
Console.shared.configure(in: window)
/// - Note: Log something with AELog
aelog()
return true
}
// MARK: - Additional Console API
/// - Note: Check if Console is hidden
Console.shared.isHidden
/// - Note: Toggle Console visibility
Console.shared.toggle()
/// - Note: Add any log line manually
Console.shared.addLogLine(line: "Hello!")
/// - Note: Export log file manually
Console.shared.exportLogFile { (fileURL) in
do {
let url = try fileURL()
/// - Note: do something with a log file at given file URL...
} catch {
print(error)
}
}
这应该解释了控制台 UI 的所有功能特性
功能 | 描述 |
---|---|
导出日志 | 将在应用程序文档目录中创建 AELog_{时间戳}.txt 文件并显示共享表。 |
过滤日志 | 过滤器不区分大小写。 |
切换工具栏 | 同时适用于过滤器和菜单工具栏。 |
切换转发触摸事件 | 激活时,您可以与您的应用交互;否则,您可以与日志交互。 |
切换自动跟随 | 激活时,它将自动滚动到新的日志行;否则,它将保持静止。 |
清除日志 | 您无法撤消此操作。 |
菜单工具栏上的平移手势 | 向左更透明,向右更不透明。 |
.package(url: "https://github.com/tadija/AEConsole.git", from: "0.7.2")
github "tadija/AEConsole"
pod 'AEConsole'
AEConsole 在 MIT 许可证下发布。有关详细信息,请参阅 LICENSE。