Last active
May 1, 2025 15:36
-
-
Save florentmorin/cbfe34dda1919c6fd7df9b93b5f276b9 to your computer and use it in GitHub Desktop.
Returns device model identifier for visionOS (ie. `RealityDevice14,1` for Apple Vision Pro)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func visionOSModelIdentifier() -> String { | |
if let identifier = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] { | |
return identifier | |
} else { | |
var systemInfo = utsname() | |
uname(&systemInfo) | |
let machine = Mirror(reflecting: systemInfo.machine) | |
return machine.children | |
.compactMap({ $0.value as? Int8 }) | |
.filter({ $0 != 0 }) | |
.map({ String(UnicodeScalar(UInt8($0))) }) | |
.joined() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment