With the upcoming Apple Silicon hardware, some apps may want to determine whether the CPU is an Intel or Apple one. Example // https://developer.apple.com/forums/thread/678914
var systeminfo = utsname()
uname(&systeminfo)
let machine = withUnsafeBytes(of: &systeminfo.machine) {bufPtr->String in
let data = Data(bufPtr)
if let lastIndex = data.lastIndex(where: {$0 != 0}) {
return String(data: data[0...lastIndex], encoding: .isoLatin1)!
} else {
return String(data: data, encoding: .isoLatin1)!
}
}
// arm64
print(machine)