From b56d27ff267ec0d349d99903ba2b008be5f9368f Mon Sep 17 00:00:00 2001 From: Duraid Abdul Date: Tue, 1 Jun 2021 14:46:05 -0700 Subject: [PATCH] Add OS Compile Date to System Report --- Sources/LocalConsole/LCManager.swift | 7 ++++--- Sources/LocalConsole/SystemReport.swift | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Sources/LocalConsole/LCManager.swift b/Sources/LocalConsole/LCManager.swift index 4fb7140..ac4069a 100644 --- a/Sources/LocalConsole/LCManager.swift +++ b/Sources/LocalConsole/LCManager.swift @@ -309,17 +309,18 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate { func systemReport() { DispatchQueue.main.async { [self] in print("Screen Scale: \(UIScreen.main.scale)\n") - print("Screen Size: \(UIScreen.main.bounds.size)") print("Screen Radius: \(UIScreen.main.value(forKey: "_displayCornerRadius") as! CGFloat)") + print("Screen Size: \(UIScreen.main.bounds.size)") print("Max Frame Rate: \(UIScreen.main.maximumFramesPerSecond) Hz") print("Low Power Mode: \(ProcessInfo.processInfo.isLowPowerModeEnabled)") print("System Uptime: \(Int(ProcessInfo.processInfo.systemUptime))s") print("Thermal State: \(SystemReport.shared.thermalState)") print("Processor Cores: \(Int(ProcessInfo.processInfo.processorCount))") print("Memory: \(round(100 * Double(ProcessInfo.processInfo.physicalMemory) * pow(10, -9)) / 100) GB") - print("Firmware: \(SystemReport.shared.gestaltFirmwareVersion)") - print("Kernel Version: \(SystemReport.shared.kernel) \(SystemReport.shared.kernelVersion)") + print("OS Compile Date: \(SystemReport.shared.compileDate)") print("System Version: \(SystemReport.shared.versionString)") + print("Kernel Version: \(SystemReport.shared.kernel) \(SystemReport.shared.kernelVersion)") + print("Firmware: \(SystemReport.shared.gestaltFirmwareVersion)") print("Architecture: \(SystemReport.shared.gestaltArchitecture)") print("Model Identifier: \(SystemReport.shared.gestaltModelIdentifier)") print("Marketing Name: \(SystemReport.shared.gestaltMarketingName)") diff --git a/Sources/LocalConsole/SystemReport.swift b/Sources/LocalConsole/SystemReport.swift index 49f146c..10d819d 100644 --- a/Sources/LocalConsole/SystemReport.swift +++ b/Sources/LocalConsole/SystemReport.swift @@ -80,4 +80,29 @@ class SystemReport { sysctlbyname("kern.osrelease", &string, &size, nil, 0) return String(cString: string) } + + var compileDate: String { + var size = 0 + sysctlbyname("kern.version", nil, &size, nil, 0) + + var string = [CChar](repeating: 0, count: Int(size)) + sysctlbyname("kern.version", &string, &size, nil, 0) + let fullString = String(cString: string) /// Ex: Darwin Kernel Version 20.6.0: Mon May 10 03:15:29 PDT 2021; root:xnu-7195.140.13.0.1~20/RELEASE_ARM64_T8101 + + let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.date.rawValue) + if let matches = detector?.matches(in: fullString, options: [], range: NSRange(location: 0, length: fullString.utf16.count)) { + for match in matches { + + if let date = match.date { + + let dateformatter = DateFormatter() + dateformatter.dateStyle = .medium + + return dateformatter.string(from: date) + } + } + } + + return "Unknown" + } }