Last active
September 26, 2024 00:24
-
-
Save amosavian/87d97cee2ef38aebe5c31c5ab1201e42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>iPhone5,1</key> | |
<string>iPhone 5 (GSM)</string> | |
<key>iPhone5,2</key> | |
<string>iPhone 5 (GSM+CDMA)</string> | |
<key>iPhone5,3</key> | |
<string>iPhone 5C (GSM)</string> | |
<key>iPhone5,4</key> | |
<string>iPhone 5C (GSM+CDMA)</string> | |
<key>iPhone6,1</key> | |
<string>iPhone 5S (GSM)</string> | |
<key>iPhone6,2</key> | |
<string>iPhone 5S (GSM+CDMA)</string> | |
<key>iPhone7,1</key> | |
<string>iPhone 6 Plus</string> | |
<key>iPhone7,2</key> | |
<string>iPhone 6</string> | |
<key>iPhone8,1</key> | |
<string>iPhone 6s</string> | |
<key>iPhone8,2</key> | |
<string>iPhone 6s Plus</string> | |
<key>iPhone8,3</key> | |
<string>iPhone SE (GSM+CDMA)</string> | |
<key>iPhone8,4</key> | |
<string>iPhone SE (GSM)</string> | |
<key>iPhone9,1</key> | |
<string>iPhone 7</string> | |
<key>iPhone9,2</key> | |
<string>iPhone 7 Plus</string> | |
<key>iPhone9,3</key> | |
<string>iPhone 7</string> | |
<key>iPhone9,4</key> | |
<string>iPhone 7 Plus</string> | |
<key>iPhone10,1</key> | |
<string>iPhone 8</string> | |
<key>iPhone10,2</key> | |
<string>iPhone 8 Plus</string> | |
<key>iPhone10,3</key> | |
<string>iPhone X Global</string> | |
<key>iPhone10,4</key> | |
<string>iPhone 8</string> | |
<key>iPhone10,5</key> | |
<string>iPhone 8 Plus</string> | |
<key>iPhone10,6</key> | |
<string>iPhone X GSM</string> | |
<key>iPhone11,2</key> | |
<string>iPhone XS</string> | |
<key>iPhone11,4</key> | |
<string>iPhone XS Max</string> | |
<key>iPhone11,6</key> | |
<string>iPhone XS Max Global</string> | |
<key>iPhone11,8</key> | |
<string>iPhone XR</string> | |
<key>iPod7,1</key> | |
<string>iPod Touch 6G</string> | |
<key>iPod9,1</key> | |
<string>iPod Touch 7G</string> | |
<key>iPad3,4</key> | |
<string>iPad 4 (WiFi)</string> | |
<key>iPad3,5</key> | |
<string>iPad 4 (GSM)</string> | |
<key>iPad3,6</key> | |
<string>iPad 4 (GSM+CDMA)</string> | |
<key>iPad4,1</key> | |
<string>iPad Air (WiFi)</string> | |
<key>iPad4,2</key> | |
<string>iPad Air (WiFi/Cellular)</string> | |
<key>iPad4,3</key> | |
<string>iPad Air (China)</string> | |
<key>iPad4,4</key> | |
<string>iPad Mini Retina (WiFi)</string> | |
<key>iPad4,5</key> | |
<string>iPad Mini Retina (WiFi/Cellular)</string> | |
<key>iPad4,6</key> | |
<string>iPad Mini Retina (China)</string> | |
<key>iPad4,7</key> | |
<string>iPad Mini 3 (WiFi)</string> | |
<key>iPad4,8</key> | |
<string>iPad Mini 3 (WiFi/Cellular)</string> | |
<key>iPad4,9</key> | |
<string>iPad Mini 3 (China)</string> | |
<key>iPad5,1</key> | |
<string>iPad Mini 4 (WiFi)</string> | |
<key>iPad5,2</key> | |
<string>iPad Mini 4 (WiFi/Cellular)</string> | |
<key>iPad5,3</key> | |
<string>iPad Air 2 (WiFi)</string> | |
<key>iPad5,4</key> | |
<string>iPad Air 2 (WiFi/Cellular)</string> | |
<key>iPad6,3</key> | |
<string>iPad Pro 9.7-inch (WiFi)</string> | |
<key>iPad6,4</key> | |
<string>iPad Pro 9.7-inch (WiFi/Cellular)</string> | |
<key>iPad6,7</key> | |
<string>iPad Pro 12.9-inch (WiFi)</string> | |
<key>iPad6,8</key> | |
<string>iPad Pro 12.9-inch (WiFi/Cellular)</string> | |
<key>iPad6,11</key> | |
<string>iPad 5 (WiFi)</string> | |
<key>iPad6,12</key> | |
<string>iPad 5 (WiFi/Cellular)</string> | |
<key>iPad7,1</key> | |
<string>iPad Pro 12.9-inch 2nd-gen (WiFi)</string> | |
<key>iPad7,2</key> | |
<string>iPad Pro 12.9-inch 2nd-gen (WiFi/Cellular)</string> | |
<key>iPad7,3</key> | |
<string>iPad Pro 10.5-inch (WiFi)</string> | |
<key>iPad7,4</key> | |
<string>iPad Pro 10.5-inch (WiFi/Cellular)</string> | |
<key>iPad7,5</key> | |
<string>iPad 6 (WiFi)</string> | |
<key>iPad7,6</key> | |
<string>iPad 6 (WiFi/Cellular)</string> | |
<key>iPad8,1</key> | |
<string>iPad Pro 11-inch (WiFi)</string> | |
<key>iPad8,2</key> | |
<string>iPad Pro 11-inch (WiFi, 1TB)</string> | |
<key>iPad8,3</key> | |
<string>iPad Pro 11-inch (Cellular)</string> | |
<key>iPad8,4</key> | |
<string>iPad Pro 11-inch (Cellular, 1TB)</string> | |
<key>iPad8,5</key> | |
<string>iPad Pro 12.9-inch 3 (WiFi)</string> | |
<key>iPad8,6</key> | |
<string>iPad Pro 12.9-inch 3 (WiFi, 1TB)</string> | |
<key>iPad8,7</key> | |
<string>iPad Pro 12.9-inch 3 (Cellular)</string> | |
<key>iPad8,8</key> | |
<string>iPad Pro 12.9-inch 3 (Cellular, 1TB)</string> | |
</dict> | |
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Device { | |
private static let devices: [String: String] = { | |
let json = Bundle.current.url(forResource: "Devices", withExtension: "plist")! | |
let data = try! Data(contentsOf: json) | |
let decoder = PropertyListDecoder() | |
return try! decoder.decode([String: String].self, from: data) | |
}() | |
private static func deviceName(for device: String) -> String { | |
return devices[device] ?? device | |
} | |
static var deviceName: String { | |
#if canImport(Darwin) | |
#if os(macOS) | |
let hwmodel = "hw.model" | |
#else | |
let hwmodel = "hw.machine" | |
#endif | |
var size: Int = 0 | |
sysctlbyname(hwmodel, nil, &size, nil, 0) | |
var machine = [UInt8].init(repeating: 0, count: size) | |
sysctlbyname(hwmodel, &machine, &size, nil, 0) | |
return deviceName(for: String(cString: machine)) | |
#else | |
#error ("Not supported") | |
#endif | |
} | |
} | |
class Decoy: NSObject { } | |
extension Bundle { | |
static var current: Bundle = Bundle(for: Decoy.self) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment