Devices 1.1.0

Devices 1.1.0

Maintained by RockerHX.

Devices 1.1.0

  • By
  • RockerHX


Version Swift4.0 Swift4.1 Swift4.2 Xcode Platform Supported License

Branch Build Status Versions
master Build Status -
Swift 5.0 Build Status ≥ 1.0.0
Swift 4.2 Build Status ≥ 0.8.0
Below Swift 4.2 Build Status < 0.7.2


  • Device identification
  • Device family detection
  • Device model detection
  • Device size detection
  • Device group detection
  • Simulator detection
  • Brightness detection
  • Battery detection
  • Equatable



Devices is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Devices"


First make sure to import the framework:

import Devices


Device family

Simple code:

func iOSDeviceFamily() {
    let family =
    switch family {
    case .iPhone:
        print("Device belong to \(family) family")
    case .unknown:
        print("unknown Device.")

Demo code: Family Demo Code

Device model

Simple code:

func iOSDeviceModel() {
    let model = Device.model()
    switch model {
    /*** iPod ***/
    case .iPodTouch6Gen:
        print("Device is a \(model)")
    /*** iPhone ***/
    case .iPhoneX:
        print("Device is a \(model)")
    /*** iPad ***/
    case .iPadPro10_5Inch:
        print("Device is a \(model)")
    /*** HomePod ***/
    case .HomePod:
        print("Device is a \(model)")
    case .simulator(.iPhoneX):
        print("Device is a \(model)")
    /*** unknown ***/
    case .unknown:
        print("unknown Device.")

Demo code: Model Demo Code

Device screen size

Simple code:

func iOSDeviceSize() {
    let size = Device.size()
    switch size {
    case .screen12_9Inch:
        print("Device size: \(size.description)")
    case .unknown:
        print("Device size unknown.")

Demo code: Size Demo Code



Simple code:

func iOSModelHelper() {
    let model = Device.model()
    let allPhones = Device.Model.allPhones
    if allPhones.contains(model) {
        print("Current device belong to iPhone ")
    let allSimulatorPhones = Device.Model.allSimulatorPhones
    if allSimulatorPhones.contains(model) {
        print("Current device belong to iPhone Simulator")

Demo code: Model Helper Demo Code


You can use operator like >, <, >=, <=, ==, !=

Simple code:

func iOSSizeHelper() {
    let size = Device.size()
    if size > .screen4_7Inch {
        print("Your device screen is larger than 4.7 inch")

    if Device.isRetina() {
        print("It's a retina display")

Demo code: Size Helper Demo Code


Apple not provide api to get brightness on tvOS and watchOS, and if you want change watchOS's device brightness will be rejected. So, brightness api can only support iOS and OSX platform. iOS Simple code:

func iOSBrightness() {
    print("Device.brightness: \(Device.brightness)")
    Device.brightness = 0.8

OSX Simple code:

func OSXBrightness() {
    print("Device.Brightness.level: \(Device.Brightness.level)")
    Device.Brightness.level = .level_5
    Device.Brightness.level = .custom(0.5)


iOS Simple code:

func iOSBattery() {
    let batteryState = Device.Battery.state

    switch batteryState {
    case .full:
        print("Your battery is happy! 😊")
    case .charging(let level):
        print("Your battery level: \(level)")
    case .unplugged(let level):
        print("Your battery level: \(level)")

    if Device.Battery.lowPowerMode {
        print("Low Power mode is enabled! 🔋")
    } else {
        print("Low Power mode is disabled! 😊")

    guard batteryState < .charging(80) else {
        print("Your battery is happy! 😊")


iOS Simple code:

func iOSApplication() {
    print("Build: \(")
    print("Version: \(Device.Application.shared.version)")
    print("Name: \(")
    print("wholeVersion: \(Device.Application.shared.wholeVersion)")
    print("firstLanuch: \(Device.Application.shared.firstLanuch)")


OSX Demo Code


tvOS Demo Code


watchOS Demo Code


Device is available under the MIT license. See the LICENSE file for more info.