Super-lightweight library to detect used device
Clone or download
codytwinton Added iPhone XS, iPhone XS Max, iPhone XR (#47)
* Added iPhone XS, iPhone XS Max, iPhone XR

* Updated Changelog

* Updated README to reference targeting Swift 4.2

* Added iPhone XS, iPhone XS Max, iPhone XR

* Updated Changelog
Latest commit 4340500 Sep 26, 2018

README.md

Device.swift

Language License Platform Documentation Pod Version Carthage Compatible

Super-lightweight library to detect used device

Device.swift extends the UIDevice class by adding a property:

var deviceType: DeviceType

Install

Note: If you are trying to target Swift 4.2, make sure to target the swift-4.2 branch.

Carthage

Add the following to your Cartfile and follow these instructions

github "schickling/Device.swift"

CocoaPods

To integrate Device into your project add the following to your Podfile:

platform :ios, '8.0'
use_frameworks!

pod 'Device.swift'

Usage

import Device
// Use import Device_swift if you're using Cocoapods

let deviceType = UIDevice.current.deviceType

switch deviceType {
case .iPhone6SPlus: print("Do stuff for iPhone6S Plus")
case .iPadMini: print("Do stuff for iPad mini")
default: print("Check other available cases of DeviceType")
}

Also, check out our Documentation