Swiftpack.co - devicekit/DeviceKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
DeviceKit is a value-type replacement of UIDevice.
.package(url: "https://github.com/devicekit/DeviceKit.git", from: "4.5.0")

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.5.0

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: 3469
Last commit: 6 days ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

Version 4.5.0
1 week ago

New September 2021 devices

This version adds support for the devices announced at the September 2021 Apple Event: (#286)

Device Case value
iPhone 13 Device.iPhone13
iPhone 13 mini Device.iPhone13Mini
iPhone 13 Pro Device.iPhone13Pro
iPhone 13 Pro Max Device.iPhone13ProMax
iPad (9th generation) Device.iPad9
iPad mini (6th generation) Device.iPadMini6


  • Switched from Travis CI to GitHub Actions.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics