Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which slice will be picked by an iPhone

I have an .ipa which has arm64 and armv7 slices in it. If I run it on a iDevice which supports both arm64 and armv7 which slice will be picked by the runtime ?

Can I see somewhere by printing NSLog or some way to understand that runtime has picked slice arm64 ?

like image 204
thndrkiss Avatar asked Jan 19 '17 07:01

thndrkiss


1 Answers

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);
like image 53
Vishun Avatar answered Sep 19 '22 17:09

Vishun