Skip to content

Commit

Permalink
Merge pull request #34 from p-x9/feature/improve-device-info
Browse files Browse the repository at this point in the history
Improve device info command
  • Loading branch information
p-x9 authored Apr 8, 2024
2 parents 8df6d27 + d298538 commit 31a859a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/swift/deviceIOS.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import UIKit

var screenSize: CGSize {
guard let window = UIApplication.shared.connectedScenes.first as? UIWindowScene else {
return .zero
}
return window.screen.bounds.size
}

func printDeviceInfo() {
let currentDevice = UIDevice.current

print("[Device Info]")
print("Name: \(currentDevice.name)")
print("Model: \(currentDevice.model)")
print("IsSimulator: \(TARGET_OS_SIMULATOR != 0)")
print("System Name: \(currentDevice.systemName)")
print("System Version: \(currentDevice.systemVersion)")
print("Screen: \(screenSize.width) x \(screenSize.height)")
print("Locale: \(Locale.current)")
if let identifierForVendor = currentDevice.identifierForVendor {
print("Id For Vendor: \(identifierForVendor.uuidString)")
}
Expand Down
2 changes: 2 additions & 0 deletions src/swift/deviceMacOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ func printDeviceInfo() {
if let cpu = sysctlByString(key: "machdep.cpu.brand_string") {
print("CPU: \(cpu)")
}

print("Locale: \(Locale.current)")
}

func sysctlByString(key: String) -> String? {
Expand Down

0 comments on commit 31a859a

Please sign in to comment.