diff --git a/DeviceKit.podspec b/DeviceKit.podspec index 8c1b4f3..e843424 100644 --- a/DeviceKit.podspec +++ b/DeviceKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'DeviceKit' - s.version = '1.0.1' + s.version = '1.1.0' s.summary = 'DeviceKit is a ยต-framework that provides a value-type replacement of UIDevice.' s.description = <<-DESC diff --git a/README.md b/README.md index ef7c578..8c2999a 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,15 @@ [![Platform](https://img.shields.io/cocoapods/p/DeviceKit.svg?style=flat)](http://cocoadocs.org/docsets/DeviceKit) -| Branch | Build Status | -|:-------|:------------:| -| **master** |[![Build Status](https://travis-ci.org/dennisweissmann/DeviceKit.svg?branch=master)](https://travis-ci.org/dennisweissmann/DeviceKit)| -| **Swift 3** |[![Build Status](https://travis-ci.org/dennisweissmann/DeviceKit.svg?branch=swift-3.0)](https://travis-ci.org/dennisweissmann/DeviceKit)| -| **Swift 2.3** |[![Build Status](https://travis-ci.org/dennisweissmann/DeviceKit.svg?branch=swift-2.3-unsupported)](https://travis-ci.org/dennisweissmann/DeviceKit)| +| Branch | Build Status | Versions | +|:---------|:--------------:|:----------:| +| **master** |[![Build Status](https://travis-ci.org/dennisweissmann/DeviceKit.svg?branch=master)](https://travis-ci.org/dennisweissmann/DeviceKit)| - | +| **Swift 3** |[![Build Status](https://travis-ci.org/dennisweissmann/DeviceKit.svg?branch=swift-3.0)](https://travis-ci.org/dennisweissmann/DeviceKit)| >= 1.0 | +| **Swift 2.3** |[![Build Status](https://travis-ci.org/dennisweissmann/DeviceKit.svg?branch=swift-2.3-unsupported)](https://travis-ci.org/dennisweissmann/DeviceKit)| < 1.0 | `Device` is a value-type replacement of [`UIDevice`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/). -##Features +## Features - [x] Device identification - [x] Device family detection @@ -34,7 +34,7 @@ DeviceKit can be installed in various ways. ### CocoaPods -#### Swift 3.0 +#### Swift 3 ```ruby pod 'DeviceKit', '~> 1.0' ``` @@ -45,9 +45,9 @@ pod 'DeviceKit', :git => 'https://github.com/dennisweissmann/DeviceKit.git', :br ### Carthage -#### Swift 3.0 +#### Swift 3 ```ogdl -github "dennisweissmann/DeviceKit" "HEAD" +github "dennisweissmann/DeviceKit" ~> 1.0 ``` #### Swift 2.3 (Unsupported) ```ogdl @@ -143,6 +143,9 @@ if device.batteryLevel >= 50 { } ``` +## Source of Information +All model identifiers are taken from the following website: https://www.theiphonewiki.com/wiki/Models or extracted from the simulator app bundled with Xcode. + ## Contributing If you have the need for a specific feature that you want implemented or if you experienced a bug, please open an issue. If you extended the functionality of DeviceKit yourself and want others to use it too, please submit a pull request. diff --git a/Source/Device.swift b/Source/Device.swift index 2bd658b..b00dfd7 100644 --- a/Source/Device.swift +++ b/Source/Device.swift @@ -158,12 +158,17 @@ public enum Device { /// ![Image](https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP725/SP725ipad-mini-4.png) case iPadMini4 - /// Device is an [iPad Pro](http://www.apple.com/ipad-pro/) + /// Device is an [iPad Pro](https://support.apple.com/kb/sp723) /// /// ![Image](http://images.apple.com/v/ipad-pro/c/images/shared/buystrip/ipad_pro_large_2x.png) case iPadPro9Inch case iPadPro12Inch + /// Device is an [iPad Pro](https://support.apple.com/kb/sp723) + /// + /// ![Image](http://images.apple.com/v/ipad-pro/c/images/shared/buystrip/ipad_pro_large_2x.png) + case iPadPro10Inch + #elseif os(tvOS) /// Device is an [Apple TV](http://www.apple.com/tv/) /// @@ -232,6 +237,7 @@ public enum Device { case "iPad5,1", "iPad5,2": return iPadMini4 case "iPad6,3", "iPad6,4": return iPadPro9Inch case "iPad6,7", "iPad6,8": return iPadPro12Inch + case "iPad7,4": return iPadPro10Inch case "i386", "x86_64": return simulator(mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "iOS")) default: return unknown(identifier) } @@ -258,7 +264,7 @@ public enum Device { /// All iPads public static var allPads: [Device] { - return [.iPad2, .iPad3, .iPad4, .iPadAir, .iPadAir2, .iPadMini, .iPadMini2, .iPadMini3, .iPadMini4, .iPadPro9Inch, .iPadPro12Inch] + return [.iPad2, .iPad3, .iPad4, .iPadAir, .iPadAir2, .iPadMini, .iPadMini2, .iPadMini3, .iPadMini4, .iPadPro9Inch, .iPadPro12Inch, .iPadPro10Inch] } /// All simulator iPods @@ -306,41 +312,33 @@ public enum Device { } } - /// Returns diagonal screen length in inch as Float - public var diagonal: Float { + /// Returns diagonal screen length in inches + public var diagonal: Double { switch self { - case .iPodTouch5: return 4 - case .iPodTouch6: return 4 - case .iPhone4: return 3.5 - case .iPhone4s: return 3.5 - case .iPhone5: return 4 - case .iPhone5c: return 4 - case .iPhone5s: return 4 - case .iPhone6: return 4.7 - case .iPhone6Plus: return 5.5 - case .iPhone6s: return 4.7 - case .iPhone6sPlus: return 5.5 - case .iPhone7: return 4.7 - case .iPhone7Plus: return 5.5 - case .iPhoneSE: return 4 - case .iPad2: return 9.7 - case .iPad3: return 9.7 - case .iPad4: return 9.7 - case .iPadAir: return 9.7 - case .iPadAir2: return 9.7 - case .iPadMini: return 7.9 - case .iPadMini2: return 7.9 - case .iPadMini3: return 7.9 - case .iPadMini4: return 7.9 + // 3.5-inch phones + case .iPhone4, .iPhone4s: return 3.5 + // 4-inch phones + case .iPodTouch5, .iPodTouch6, .iPhone5, .iPhone5c, .iPhone5s, .iPhoneSE: return 4 + // 4.7-inch phones + case .iPhone6, .iPhone6s, .iPhone7: return 4.7 + // 5.5-inch phones + case .iPhone6Plus, .iPhone6sPlus, .iPhone7Plus: return 5.5 + // iPads + case .iPad2, .iPad3, .iPad4, .iPadAir, .iPadAir2: return 9.7 + // iPad Minis + case .iPadMini, .iPadMini2, .iPadMini3, .iPadMini4: return 7.9 + // iPad Pros case .iPadPro9Inch: return 9.7 case .iPadPro12Inch: return 12.9 + case .iPadPro10Inch: return 10.5 + case .simulator(let model): return model.diagonal case .unknown: return -1 } } - /// Returns screen ratio as a tuple (width: Float, height: Float) - public var screenRatio: (width: Float, height: Float) { + /// Returns screen ratio as a tuple + public var screenRatio: (width: Double, height: Double) { switch self { case .iPodTouch5: return (width: 9, height: 16) case .iPodTouch6: return (width: 9, height: 16) @@ -367,6 +365,7 @@ public enum Device { case .iPadMini4: return (width: 3, height: 4) case .iPadPro9Inch: return (width: 3, height: 4) case .iPadPro12Inch: return (width: 3, height: 4) + case .iPadPro10Inch: return (width: 3, height: 4) case .simulator(let model): return model.screenRatio case .unknown: return (width: -1, height: -1) } @@ -517,6 +516,7 @@ extension Device: CustomStringConvertible { case .iPadMini4: return "iPad Mini 4" case .iPadPro9Inch: return "iPad Pro (9.7-inch)" case .iPadPro12Inch: return "iPad Pro (12.9-inch)" + case .iPadPro10Inch: return "iPad Pro (10.5-inch)" case .simulator(let model): return "Simulator (\(model))" case .unknown(let identifier): return identifier } diff --git a/Source/Info.plist b/Source/Info.plist index 7a84553..09bc972 100644 --- a/Source/Info.plist +++ b/Source/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.1 + 1.1.0 CFBundleSignature ???? CFBundleVersion