Swiftpack.co - Package - devicekit/DeviceKit
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

GitHub license CocoaPods Compatible Carthage Compatible codecov CocoaPods Maintainability Platform

Branch Build Status Versions
master Build Status ≥ 2.0
Swift 4 - 4.2 Build Status ≥ 1.3 < 1.13
Swift 3 Build Status ≥ 1.0 < 1.3
Swift 2.3 Build Status < 1.0

DeviceKit is a value-type replacement of UIDevice.

Current version 4.2.1

See our detailed changelog for the latest features, improvements and bug fixes.


  • ☑ Equatable
  • ☑ Device identification
  • ☑ Device family detection
  • ☑ Device group detection
  • ☑ Simulator detection
  • ☑ Battery state
  • ☑ Battery level
  • ☑ Various device metrics (e.g. screen size, screen ratio, PPI)
  • ☑ Low Power Mode detection
  • ☑ Guided Access Session detection
  • ☑ Screen brightness
  • ☑ Display Zoom detection
  • ☑ Detect available sensors (Touch ID, Face ID)
  • ☑ Detect available disk space
  • ☑ Apple Pencil support detection


  • iOS 9.0+ (linking against iOS 9.3 required)
  • tvOS 9.0+ (linking against tvOS 9.2 required)
  • watchOS 2.0+


DeviceKit can be installed in various ways.


Swift 5

pod 'DeviceKit', '~> 4.0'

iOS 8.0 support

pod 'DeviceKit', '3.2'

Swift 4.0 - Swift 4.2

pod 'DeviceKit', '~> 1.3'

Swift 3

pod 'DeviceKit', '~> 1.2.3'

Swift 2.3 (Unsupported)

pod 'DeviceKit', :git => 'https://github.com/devicekit/DeviceKit.git', :branch => 'swift-2.3-unsupported'

Swift Package Manager

Swift 5

dependencies: [
    .package(url: "https://github.com/devicekit/DeviceKit.git", from: "4.0.0"),
    /// ...

iOS 8.0 support

dependencies: [
    .package(url: "https://github.com/devicekit/DeviceKit.git", from: "3.2.0"),
    /// ...


Swift 5

github "devicekit/DeviceKit" ~> 4.0

iOS 8.0 support

github "devicekit/DeviceKit" ~> 3.2

Swift 4.0 - Swift 4.2

github "devicekit/DeviceKit" ~> 1.3

Swift 3

github "devicekit/DeviceKit" ~> 1.2.3

Swift 2.3 (Unsupported)

github "devicekit/DeviceKit" "swift-2.3-unsupported"


To install it manually, drag the DeviceKit project into your app project in Xcode. Or add it as a git submodule by running:

$ git submodule add https://github.com/devicekit/DeviceKit.git


First make sure to import the framework:

import DeviceKit

Here are some usage examples. All devices are also available as simulators:

.iPhone6 => .simulator(.iPhone6)
.iPhone6s => .simulator(.iPhone6s)

You can try these examples in Playground.


To try DeviceKit in the playground, open the DeviceKit.xcworkspace and build DeviceKit.framework for any simulator first by selecting "DeviceKit" as your current scheme.

Get the Device You're Running On

let device = Device.current

print(device)     // prints, for example, "iPhone 6 Plus"

if device == .iPhone6Plus {
  // Do something
} else {
  // Do something else

Get the Device Family

let device = Device.current
if device.isPod {
  // iPods (real or simulator)
} else if device.isPhone {
  // iPhone (real or simulator)
} else if device.isPad {
  // iPad (real or simulator)

Check If Running on Simulator

let device = Device.current
if device.isSimulator {
  // Running on one of the simulators(iPod/iPhone/iPad)
  // Skip doing something irrelevant for Simulator

Get the Simulator Device

let device = Device.current
switch device {
case .simulator(.iPhone6s): break // You're running on the iPhone 6s simulator
case .simulator(.iPadAir2): break // You're running on the iPad Air 2 simulator
default: break

Make Sure the Device Is Contained in a Preconfigured Group

let groupOfAllowedDevices: [Device] = [.iPhone6, .iPhone6Plus, .iPhone6s, .iPhone6sPlus, .simulator(.iPhone6), .simulator(.iPhone6Plus),.simulator(.iPhone6s),.simulator(.iPhone6sPlus).simulator(.iPhone8),.simulator(.iPhone8Plus),.simulator(.iPhoneX),.simulator(.iPhoneXS),.simulator(.iPhoneXSMax),.simulator(.iPhoneXR)]

let device = Device.current
if device.isOneOf(groupOfAllowedDevices) {
  // Do your action

Get the Current Battery State


To get the current battery state we need to set UIDevice.current.isBatteryMonitoringEnabled to true. To avoid any issues with your code, we read the current setting and reset it to what it was before when we're done.

if device.batteryState == .full || device.batteryState >= .charging(75) {
  print("Your battery is happy! 😊")

Get the Current Battery Level

if device.batteryLevel >= 50 {
} else {

Get Low Power mode status

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

Check if a Guided Access session is currently active

if device.isGuidedAccessSessionActive {
  print("Guided Access session is currently active")
} else {
  print("No Guided Access session is currently active")

Get Screen Brightness

if device.screenBrightness > 50 {
  print("Take care of your eyes!")

Get Available Disk Space

if Device.volumeAvailableCapacityForOpportunisticUsage ?? 0 > Int64(1_000_000) {
  // download that nice-to-have huge file

if Device.volumeAvailableCapacityForImportantUsage ?? 0 > Int64(1_000) {
  // download that file you really need

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.


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.


The complete list of people who contributed to this project is available here. DeviceKit wouldn't be what it is without you! Thank you very much! 🙏


Stars: 3228


Version 4.2.1 - 2020-10-22T18:08:19

Fix bugs in v4.2.0 release:

  • Device.allDevicesWithALidarSensor didn't include iPhone 12 Pro and iPhone 12 Pro Max. (#268 #266)
  • Device.iPadAir4.screenRatio returned an invalid screen ratio. (#268 #267)

Version 4.2.0 - 2020-10-21T15:38:51

This release will add support for the October 2020 devices. (#262)

  • iPad Air (4th generation)
  • iPhone 12
  • iPhone 12 mini
  • iPhone 12 Pro
  • iPhone 12 Pro Max

The technical identifiers are there. Images and support links will be added in a feature release. Thanks @Zandor300 🎉.

Version 4.1.0 - 2020-09-21T12:04:33

This release will add support for the September 2020 devices, which will be released on the 18th of September: (#256)

  • iPad (8th generation)
  • Apple Watch Series 6
  • Apple Watch SE



Support for iPad Air (4th generation) will be added in a later version since it will be a long time before we know its device identifiers.

Version 4.0.0 - 2020-09-04T14:34:19

This is a v4.0.0 release because of the possibly breaking change of no longer supporting iOS 9. This decision was made because of Xcode 12 no longer supporting iOS 8.

  • Dropped support for iOS 8. Lowest supported version is now iOS 9. (#249)
  • Updated project settings for Xcode 12. (#248)

Version 3.2.0: Add support for iPhone SE (2nd generation) - 2020-04-30T07:30:26

Added support for the iPhone SE (2nd generation). (#238)

Thanks @Zandor300 🎉

Version 3.1.0: Add support for the 2020 iPad Pro - 2020-03-29T19:15:20

Thank you @Zandor300 and everyone who opened issues and provided pull requests! 🥳

2020 iPad Pro

  • Added support for the new 2020 iPad Pro. (#235)
Device.iPadPro11Inch2 // iPad Pro (11-inch) (2nd generation)
Device.iPadPro12inch4 // iPad Pro (12.9-inch) (4th generation)

New features

  • Added new functions for detecting LiDAR support.
    • Device.allDevicesWithALidarSensor and Device.current.hasLidarSensor

Version 3.0.0 - 2020-01-20T06:21:06

Thank you @Zandor300 and everyone who opened issues and provided pull requests! 🥳

Breaking changes

  • The enum for the Apple TV HD has been renamed from .appleTV4 to .appleTVHD. (#211)
  • .allSimulatorXSeriesDevices has been deprecated and replaced by .allSimulatorDevicesWithSensorHousing. (#212)
  • .allXSeriesDevices has been deprecated and replaced by .allDevicesWithSensorHousing. (#212)


  • CameraTypes has been renamed to CameraType. (#212)
  • CameraType.normal has been deprecated and replaced by CameraType.wide. (#212)
  • .allDevicesWithNormalCamera has been deprecated and replaced by .allDevicesWithWideCamera. (#212)
  • .hasNormalCamera has been deprecated and replaced by .hasWideCamera. (#212)

New features

  • You can now check which devices support wireless charging through the following variables: Device.allDevicesWithWirelessChargingSupport and Device.current.supportsWirelessCharging (#209)
  • New .safeDescription variable that will provide you with a safe version of the .description variable. (#212)
    • Example: "iPhone Xʀ" vs "iPhone XR"


  • .allDevicesWith3dTouchSupport contained .iPhoneSE which was incorrect. (#226)
  • Some variables would return incorrect values when running on the simulator. (#227)

Version 2.3.0 - 2019-10-02T08:57:38

Thank you @Zandor300 🎉!

New devices

  • Added support for the new September 2019 devices:
    • iPad (7th generation)

Version 2.2.0 - 2019-09-24T10:07:47

Thank you to all the contributors and a special thanks to @Zandor300 🎉!

New devices

  • Added support for the new September 2019 devices:
    • iPhone 11
    • iPhone 11 Pro
    • iPhone 11 Pro Max
    • Apple Watch Series 5

Support for iPad (7th generation) will be added later.

New features

  • Device.current.cameras now has the .ultraWide camera type added for devices with that camera.

Version 2.1.0 - 2019-09-01T14:12:50

Thank you for all for your contributions and a special thank you to @Zandor300! 🎉

New features

  • Add support for the new iPod touch (7th generation) (#189)
  • Added Device.allApplePencilCapableDevices and Device.current.applePencilSupport variables for checking Apple Pencil support. (#179)
    • .applePencilSupport returns ApplePencilSupport.firstGeneration or ApplePencilSupport.secondGeneration for checking which Apple Pencil is supported.
  • Added 3D Touch (iOS) and Force Touch (watchOS) support variables: (#183)
    • iOS
      • Device.allDevicesWith3dTouchSupport
      • Device.current.has3dTouchSupport
    • watchOS
      • Device.allWatchesWithForceTouchSupport
      • Device.current.hasForceTouchSupport
  • Added variable to check for the camera's a device has. (#188)
    • Example: Device.iPhoneXS.cameras should return CameraTypes.normal and CameraTypes.telephoto.


  • Rename iPod touch 5 and 6 to iPod touch (5th generation) and iPod touch (6th generation) respectively. (#189)
  • Rename Apple TV (4th generation) to Apple TV HD to comply with Apple's rename of the device. (#196)
  • Improve support for Swift Package Manager. (#193)
  • Fixed the Device.current.isZoomed variable. (#59 comment and #198)

Version 2.0 - 2019-04-10T17:13:28

Version 2.0 release 🎉

Thank you to all the contributors who made this release happen 💕 and a special thank you to @Zandor300 for all his effort and working closely with me to release this version 😊.

Breaking changes

  • The original Device() constructor has been made private in favour of using Device.current to match UIDevice.current.
  • The enum values for the iPhone Xs, iPhone Xs Max and iPhone Xʀ have been renamed to be .iPhoneXS, .iPhoneXSMax and .iPhoneXR to match proper formatting.
  • .description for the iPhone Xs, iPhone Xs Max and iPhone Xʀ have been changed to contain small caps formatting for the s and the ʀ part.
  • .description for the iPad 5 and iPad 6 have been changed to the proper names; iPad (5th generation) and iPad (6th generation).
  • .name, .systemName, .systemVersion, .model, .localizedModel, .batteryState and .batteryLevel will now all return nil when you try to get its value when the device you are getting it from isn't the current one. (eg. Device.iPad6.name while running on iPad 5)

New features

  • Updated to Swift 5!
  • New .allDevicesWithRoundedDisplayCorners and .hasRoundedDisplayCorners values to check if a device has rounded display corners. (eg. iPhone Xs and iPad Pro (3rd generation))
  • new .allDevicesWithSensorHousing and .hasSensorHousing values to check if a device has a screen cutout for the sensor housing. (eg. iPhone Xs)


  • .isPad and .isPhone are now giving correct outputs again.

Bugfixes - 2018-12-12T10:51:23

Thank you @phimage for this!

Support for new iPad Pro (11" and 12.9" 3rd Gen) - 2018-11-01T12:08:29

watchOS ⌚️ - 2018-10-11T20:20:30

Yes, you read that right, watchOS support.

Huge thanks to @robbiet480 for implementing this 100%

Add support for Swift < 4.2 to latest model update - 2018-09-18T17:17:16

Support for iPhone Xs, iPhone Xs Max and iPhone Xr - 2018-09-17T19:01:10

Thanks to all who contributed, especially @mishagray

Device Orientation and Disk Space - 2018-04-13T16:43:21

Thanks to @mumer92 for the device orientation feature and @phimage for the disk space feature! 🎉

Bugfixes and Support for iPad 6 - 2018-04-04T16:37:37

This fixes several bugs:

  • Documentation issues
  • isZoomed for iPhone falsely returned true
  • reset UIDevice.current.isBatteryMonitoringEnabled to what is was before so we don't interfere with user code
  • add support for iPad 6

Low Power Mode Detection, Screen Brightness and isGuidedAccessSessionActive - 2018-01-29T10:36:13

Big thanks to @bugix and @gianpispi 🎉

New Features AND Bugfixes (new devices and more methods) - 2017-09-23T11:10:43

  • new device identifiers for iPhone 8, Plus and X
  • support for Apple TV 4K
  • support for HomePod
  • iOS devices have two new properties: allPlusSizedDevices and allProDevices

Fix for AppStore Upload - 2017-09-21T16:19:43

Remove code coverage instrumentation

Thanks @walsht <3

Fix for Carthage - 2017-09-21T04:46:06

Sorry for the trouble everyone, Carthage doesn’t like the new build system :( so I switched back to the old one.

Bug fixes - 2017-09-17T15:22:22

Include new iPhones in the generated file

Support for iPhone 8, iPhone 8 Plus and iPhone X - 2017-09-17T11:05:32

add support for iPad 5, iPad Pro 10.5 and iPad Pro 12.9 inch Gen 2 - 2017-06-11T16:56:14

add support for iPad 5, iPad Pro 10.5 and iPad Pro 12.9 inch Gen 2 - 2017-06-11T11:43:43

Support for iPad Pro 10.5 - 2017-06-08T05:24:50

Bugfixes and New Functionality - 2017-01-15T10:20:47

adds diagonal and screenRatio properties (thank you @geniejhang!) adds the iPhone5c to the allPhones property (thank you @LeonardoCardoso) uses a new method to get the device identifier (thank you @kdawgwilk)

Stable Release - Swift 3.0 - 2016-09-10T21:55:18

I want to thank everyone for contributing and using DeviceKit! 🎉

Add Support for iPhone 7 and iPhone 7 Plus - 2016-09-10T21:11:28

** This is the last release supporting Swift 2.x **