What's the device code (platform string) for iPhone 5 / 5c / 5s / iPod touch 5?

后端 未结 9 687
余生分开走
余生分开走 2021-01-31 10:18

For example, is it \"iPhone5,1\" or \"iPhone5,2\" for iPhone 5? And what\'s the difference?

If anyone has the iPhone 5, please help by running the following code and sho

相关标签:
9条回答
  • 2021-01-31 10:38

    It looks like either iPhone5,1 or iPhone5,2 depending on the model of iPhone 5.

    From @marcoarment, who is a well known iOS Developer:

    iPhone5,1: model A1428, AT&T/Canada

    iPhone5,2: model A1429, all others

    A1429 may have two modes, but I don’t see any iPhone5,3 records.

    Source: https://twitter.com/marcoarment/status/249249183029161984

    0 讨论(0)
  • 2021-01-31 10:39

    This method covers all devices in market:

    - (NSString *) platform{
    int mib[2];
    size_t len;
    char *machine;
    
    mib[0] = CTL_HW;
    mib[1] = HW_MACHINE;
    sysctl(mib, 2, NULL, &len, NULL, 0);
    machine = malloc(len);
    sysctl(mib, 2, machine, &len, NULL, 0);
    
    NSString *platform = [NSString stringWithCString:machine encoding:NSASCIIStringEncoding];
    free(machine);
    return platform; }
    
    - (NSString *) platformString{
    NSString *platform = [self platform];
    if ([platform isEqualToString:@"iPhone1,1"])    return @"iPhone 1G";
    if ([platform isEqualToString:@"iPhone1,2"])    return @"iPhone 3G";
    if ([platform isEqualToString:@"iPhone2,1"])    return @"iPhone 3GS";
    if ([platform isEqualToString:@"iPhone3,1"])    return @"iPhone 4";
    if ([platform isEqualToString:@"iPhone3,3"])    return @"Verizon iPhone 4";
    if ([platform isEqualToString:@"iPhone4,1"])    return @"iPhone 4S";
    if ([platform isEqualToString:@"iPhone5,1"])    return @"iPhone 5 (GSM)";
    if ([platform isEqualToString:@"iPhone5,2"])    return @"iPhone 5 (GSM+CDMA)";
    if ([platform isEqualToString:@"iPhone5,3"])    return @"iPhone 5c (GSM+CDMA)";
    if ([platform isEqualToString:@"iPhone5,4"])    return @"iPhone 5c (UK+Europe+Asia+China)";
    if ([platform isEqualToString:@"iPhone6,1"])    return @"iPhone 5s (GSM+CDMA)";
    if ([platform isEqualToString:@"iPhone6,2"])    return @"iPhone 5s (UK+Europe+Asia+China)";
    if ([platform isEqualToString:@"iPhone7,1"])    return @"iPhone 6 Plus";
    if ([platform isEqualToString:@"iPhone7,2"])    return @"iPhone 6";
    if ([platform isEqualToString:@"iPhone8,1"])    return @"iPhone 6s";
    if ([platform isEqualToString:@"iPhone8,2"])    return @"iPhone 6s Plus";
    if ([platform isEqualToString:@"iPhone8,4"])    return @"iPhone SE";
    if ([platform isEqualToString:@"iPhone9,1"])    return @"iPhone 7";
    if ([platform isEqualToString:@"iPhone9,2"])    return @"iPhone 7 Plus";
    if ([platform isEqualToString:@"iPhone9,3"])    return @"iPhone 7";
    if ([platform isEqualToString:@"iPhone9,4"])    return @"iPhone 7 Plus";
    
    
    if ([platform isEqualToString:@"iPod1,1"])      return @"iPod Touch 1G";
    if ([platform isEqualToString:@"iPod2,1"])      return @"iPod Touch 2G";
    if ([platform isEqualToString:@"iPod3,1"])      return @"iPod Touch 3G";
    if ([platform isEqualToString:@"iPod4,1"])      return @"iPod Touch 4G";
    if ([platform isEqualToString:@"iPod5,1"])      return @"iPod Touch 5G";
    
    if ([platform isEqualToString:@"iPad1,1"])      return @"iPad";
    if ([platform isEqualToString:@"iPad1,2"])      return @"iPad 3G";
    if ([platform isEqualToString:@"iPad2,1"])      return @"iPad 2 (WiFi)";
    if ([platform isEqualToString:@"iPad2,2"])      return @"iPad 2";
    if ([platform isEqualToString:@"iPad2,3"])      return @"iPad 2 (CDMA)";
    if ([platform isEqualToString:@"iPad2,4"])      return @"iPad 2";
    if ([platform isEqualToString:@"iPad2,5"])      return @"iPad Mini (WiFi)";
    if ([platform isEqualToString:@"iPad2,6"])      return @"iPad Mini";
    if ([platform isEqualToString:@"iPad2,7"])      return @"iPad Mini (GSM+CDMA)";
    if ([platform isEqualToString:@"iPad3,1"])      return @"iPad 3 (WiFi)";
    if ([platform isEqualToString:@"iPad3,2"])      return @"iPad 3 (GSM+CDMA)";
    if ([platform isEqualToString:@"iPad3,3"])      return @"iPad 3";
    if ([platform isEqualToString:@"iPad3,4"])      return @"iPad 4 (WiFi)";
    if ([platform isEqualToString:@"iPad3,5"])      return @"iPad 4";
    if ([platform isEqualToString:@"iPad3,6"])      return @"iPad 4 (GSM+CDMA)";
    if ([platform isEqualToString:@"iPad4,1"])      return @"iPad Air (WiFi)";
    if ([platform isEqualToString:@"iPad4,2"])      return @"iPad Air (Cellular)";
    if ([platform isEqualToString:@"iPad4,4"])      return @"iPad Mini 2 (WiFi)";
    if ([platform isEqualToString:@"iPad4,5"])      return @"iPad Mini 2 (Cellular)";
    if ([platform isEqualToString:@"iPad4,6"])      return @"iPad Mini 2";
    if ([platform isEqualToString:@"iPad4,7"])      return @"iPad Mini 3";
    if ([platform isEqualToString:@"iPad4,8"])      return @"iPad Mini 3";
    if ([platform isEqualToString:@"iPad4,9"])      return @"iPad Mini 3";
    if ([platform isEqualToString:@"iPad5,3"])      return @"iPad Air 2";
    if ([platform isEqualToString:@"iPad5,4"])      return @"iPad Air 2";
    
    
    if ([platform isEqualToString:@"i386"])         return @"Simulator";
    if ([platform isEqualToString:@"x86_64"])       return @"Simulator";
    return platform; }
    
    0 讨论(0)
  • 2021-01-31 10:44

    [Update]
    iPhone10,1 : iPhone 8
    iPhone10,2 : iPhone 8 Plus
    iPhone10,3 : iPhone X Global
    iPhone10,4 : iPhone 8
    iPhone10,5 : iPhone 8 Plus
    iPhone10,6 : iPhone X GSM
    iPhone11,2 : iPhone XS
    iPhone11,4 : iPhone XS Max
    iPhone11,6 : iPhone XS Max Global
    iPhone11,8 : iPhone XR
    iPhone12,1 : iPhone 11
    iPhone12,3 : iPhone 11 Pro
    iPhone12,5 : iPhone 11 Pro Max
    iPhone12,8 : iPhone SE 2nd Gen

    0 讨论(0)
  • 2021-01-31 10:45

    The Verizon iPhone 5 returns "iPhone5,2". The GSM phone returns "iPhone5,1".

    0 讨论(0)
  • 2021-01-31 10:50

    You can find a list of all iOS device identifiers here (including iPhone 5 models and iPad mini): http://theiphonewiki.com/wiki/index.php?title=Models

    The identifiers of the latest models are:

    iPhone 5: iPhone5,1 and iPhone5,2

    iPhone 5C: iPhone5,3 and iPhone5,4

    iPhone 5S: iPhone6,1 and iPhone6,2

    iPhone 6: iPhone7,2

    iPhone 6 Plus: iPhone7,1

    iPhone 6S: iPhone8,1

    iPhone 6S Plus: iPhone8,2

    iPhone SE: iPhone8,4

    iPhone 7: iPhone9,1 and iPhone9,3

    iPhone 7 Plus: iPhone9,2 and iPhone9,4

    iPhone 8: iPhone10,1 and iPhone10,4

    iPhone 8 Plus: iPhone10,2 and iPhone10,5

    iPhone X: iPhone10,3 and iPhone10,6

    EDIT: I also made an updated version of the popular iOS Support Matrix including all models up to iPhone X.

    0 讨论(0)
  • 2021-01-31 10:50

    I created a library for detecting the device at runtime.

    It's called SDVersion.

    Thought some may found it useful.

    0 讨论(0)
提交回复
热议问题