CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

UIDeviceModel 2.0.0

UIDeviceModel 2.0.0

Maintained by theoriginalbit.



  • By
  • theoriginalbit

UIDeviceModel

Language License Pod Version Carthage Compatible

A µframework to detect the device model provided through an extension of UIDevice. It also allows detection of the simulator and the device model it is simulating.

Installation

CocoaPods

pod 'UIDeviceModel', '~> 1.0'

Carthage

github "theoriginalbit/UIDeviceModel"

Usage

First import the framework:

import UIDeviceModel

Common usage would be to use in a switch statement

let deviceModel = UIDevice.current.deviceModel

switch deviceModel {
case .iPhone6sPlus: break // You're on an iPhone 6s Plus
case .iPhoneXS: break // You're on an iPhone XS
case .simulator: break // Oh, hello there developer!
default: break
}

If needed you can unwrap a simulator to get the device model being simulated

let deviceModel = UIDevice.current.deviceModel.unwrapIfSimulator

// Or as an enum

switch deviceModel {
case .simulator(let simulatedDeviceModel): break // It's as if it never happened
default: break
}