Skip to content

Instantly share code, notes, and snippets.

@florentmorin
Last active May 1, 2025 15:36
Show Gist options
  • Save florentmorin/cbfe34dda1919c6fd7df9b93b5f276b9 to your computer and use it in GitHub Desktop.
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)
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