You could try this way. You will have to add more options of cpu_type_t.
func getCPUType() -> String {
var size: size_t = 0
var type: cpu_type_t = 0
var subtype: cpu_subtype_t = 0
size = MemoryLayout<cpu_type_t>.size;
sysctlbyname("hw.cputype", &type, &size, nil, 0);
size = MemoryLayout<cpu_subtype_t>.size;
sysctlbyname("hw.cpusubtype", &subtype, &size, nil, 0);
// values for cputype and cpusubtype defined in mach/machine.h
var cpu = ""
if (type == CPU_TYPE_X86)
{
cpu += "x86"
} else if (type == CPU_TYPE_VAX) {
cpu += "vax"
} else if (type == CPU_TYPE_ARM) {
cpu += "ARM"
switch(subtype)
{
case CPU_SUBTYPE_ARM_V7:
cpu += "V7"
break;
// ...
default: break
}
}
return cpu
}
Edited: First try with "hw.cpufamily"
sysctlbyname("hw.cpufamily", &type, &size, nil, 0);