Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.

Feature/compabilite2018 iphone #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 14 additions & 3 deletions Framework/Dotzu/Dotzu/DeviceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

enum DeviceModel {
public enum DeviceModel {

case iPhone4
case iPhone4S
Expand All @@ -22,6 +22,12 @@ enum DeviceModel {
case iPhoneSE
case iPhone7
case iPhone7Plus
case iPhone8
case iPhone8Plus
case iPhoneX
case iPhoneXR
case iPhoneXS
case iPhoneXSMax
case iPad1
case iPad2
case iPad3
Expand All @@ -42,10 +48,9 @@ enum DeviceModel {
case simulator
case unknown

static var current: DeviceModel {
public static var current: DeviceModel {
var systemInfo = utsname()
uname(&systemInfo)

guard let bytesString = NSString(bytes: &systemInfo.machine, length: Int(_SYS_NAMELEN),
encoding: String.Encoding.ascii.rawValue) else {return .unknown}
guard let versionCode = String(validatingUTF8: bytesString.utf8String!) else { return .unknown }
Expand All @@ -63,6 +68,12 @@ enum DeviceModel {
case "iPhone8,4": return .iPhoneSE
case "iPhone9,1", "iPhone9,3": return .iPhone7
case "iPhone9,2", "iPhone9,4": return .iPhone7Plus
case "iPhone10,1", "iPhone10,4": return .iPhone8
case "iPhone10,2", "iPhone10,5": return .iPhone8Plus
case "iPhone10,3", "iPhone10,6": return .iPhoneX
case "iPhone11,1", "iPhone11,8": return .iPhoneXR
case "iPhone11,2", "iPhone11,3": return .iPhoneXS
case "iPhone11,4", "iPhone11,5", "iPhone11,6": return .iPhoneXSMax
case "iPad1,1": return .iPad1
case "iPad2,1", "iPad2,2", "iPad2,3", "iPad2,4": return .iPad2
case "iPad3,1", "iPad3,2", "iPad3,3": return .iPad3
Expand Down