Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for simulator device family #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions UIDevice-Hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ typedef NS_ENUM(NSUInteger, UIDeviceFamily) {
UIDeviceFamilyiPod,
UIDeviceFamilyiPad,
UIDeviceFamilyAppleTV,
UIDeviceFamilySimulatoriPad,
UIDeviceFamilySimulatoriPhone,
UIDeviceFamilyUnknown,
};

Expand Down
15 changes: 10 additions & 5 deletions UIDevice-Hardware.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ - (NSString *)modelNameForModelIdentifier:(NSString *)modelIdentifier
if ([modelIdentifier isEqualToString:@"iPhone7,2"]) return @"iPhone 6";
if ([modelIdentifier isEqualToString:@"iPhone8,1"]) return @"iPhone 6s";
if ([modelIdentifier isEqualToString:@"iPhone8,2"]) return @"iPhone 6s Plus";

// iPad http://theiphonewiki.com/wiki/IPad

if ([modelIdentifier isEqualToString:@"iPad1,1"]) return @"iPad 1G";
Expand All @@ -81,7 +81,7 @@ - (NSString *)modelNameForModelIdentifier:(NSString *)modelIdentifier
if ([modelIdentifier isEqualToString:@"iPad4,2"]) return @"iPad Air (Cellular)";
if ([modelIdentifier isEqualToString:@"iPad5,3"]) return @"iPad Air 2 (Wi-Fi)";
if ([modelIdentifier isEqualToString:@"iPad5,4"]) return @"iPad Air 2 (Cellular)";

// iPad Mini http://theiphonewiki.com/wiki/IPad_mini

if ([modelIdentifier isEqualToString:@"iPad2,5"]) return @"iPad mini 1G (Wi-Fi)";
Expand All @@ -106,15 +106,15 @@ - (NSString *)modelNameForModelIdentifier:(NSString *)modelIdentifier
if ([modelIdentifier isEqualToString:@"iPod4,1"]) return @"iPod touch 4G";
if ([modelIdentifier isEqualToString:@"iPod5,1"]) return @"iPod touch 5G";
if ([modelIdentifier isEqualToString:@"iPod7,1"]) return @"iPod touch 6G"; // as 6,1 was never released 7,1 is actually 6th generation

// Apple TV https://www.theiphonewiki.com/wiki/Apple_TV

if ([modelIdentifier isEqualToString:@"AppleTV1,1"]) return @"Apple TV 1G";
if ([modelIdentifier isEqualToString:@"AppleTV2,1"]) return @"Apple TV 2G";
if ([modelIdentifier isEqualToString:@"AppleTV3,1"]) return @"Apple TV 3G";
if ([modelIdentifier isEqualToString:@"AppleTV3,2"]) return @"Apple TV 3G"; // small, incremental update over 3,1
if ([modelIdentifier isEqualToString:@"AppleTV5,3"]) return @"Apple TV 4G"; // as 4,1 was never released, 5,1 is actually 4th generation

// Simulator
if ([modelIdentifier hasSuffix:@"86"] || [modelIdentifier isEqual:@"x86_64"])
{
Expand All @@ -132,6 +132,11 @@ - (UIDeviceFamily) deviceFamily
if ([modelIdentifier hasPrefix:@"iPod"]) return UIDeviceFamilyiPod;
if ([modelIdentifier hasPrefix:@"iPad"]) return UIDeviceFamilyiPad;
if ([modelIdentifier hasPrefix:@"AppleTV"]) return UIDeviceFamilyAppleTV;
if ([modelIdentifier hasSuffix:@"86"] || [modelIdentifier isEqual:@"x86_64"])
{
BOOL smallerScreen = ([[UIScreen mainScreen] bounds].size.width < 768.0);
return (smallerScreen ? UIDeviceFamilySimulatoriPhone : UIDeviceFamilySimulatoriPad);
}
return UIDeviceFamilyUnknown;
}

Expand Down