Skip to content

Commit

Permalink
Add OS Compile Date to System Report
Browse files Browse the repository at this point in the history
  • Loading branch information
duraidabdul committed Jun 1, 2021
1 parent c7fe1da commit b56d27f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Sources/LocalConsole/LCManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
25 changes: 25 additions & 0 deletions Sources/LocalConsole/SystemReport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit b56d27f

Please sign in to comment.