A modern Swift library for identifying iPhones and iPads and reading their hardware capabilities. Based on DeviceKit, built for iOS and iPadOS 18+ with Swift 6.
SwiftDeviceKit combines a device catalog written entirely in Swift with optional
system utilities. It has no external dependencies, uses Sendable value types
and provides @MainActor isolation for UIKit-backed APIs.
import SwiftDeviceKitCore
let device = Device.current
print(device.realDevice.description)
print(device.cpu)
print(device.hasDynamicIsland)Requires iOS / iPadOS 18+ and a toolchain with Swift 6.4 or newer.
Add this repository in Xcode's package dependencies:
https://github.com/Anywhere-Music-Player/SwiftDeviceKit
Then select the product you need.
| Module | What it provides |
|---|---|
SwiftDeviceKitCore |
Device identification, simulator and preview detection, model names, screens, cameras, processors and hardware capabilities. |
SwiftDeviceKitSystem |
Core plus battery, thermal state, storage, orientation, brightness and system information. |
Choose Core for device identification and catalog data. Choose System when you also need the current device's state.
System includes Core and exposes the same Device type, so a single
import SwiftDeviceKitSystem gives access to both. Both modules share one
package version. Core can be used without UIKit.
Look up a model by its hardware identifier or work with Device.current:
import SwiftDeviceKitCore
let device = Device.mapToDevice(identifier: "iPhone19,2")
print(device.description) // iPhone 18 Pro
print(device.hasUSBCConnectivity) // true
print(device.hasLidarSensor) // true
print(device.cameras) // wide, telephoto, ultraWide
let phones = Device.allPhones
let iPads = Device.allPads
let devicesWithFaceID = Device.allFaceIDCapableDevicesThe catalog covers iPhone and iPad models supporting iOS / iPadOS 18 or later.
Unknown identifiers are preserved as .unknown(identifier). Simulator models
expose the hardware capabilities of the device they represent.
Each device exposes its built-in screen specifications:
import SwiftDeviceKitCore
for screen in Device.current.screens {
print(screen.role, screen.diagonal, screen.ppi)
}Single-screen models have one .main screen. iPhone Duo exposes .outer and
.inner screens, each with its own specifications. These describe the hardware;
use your app's view geometry for the current layout.
See screen specifications for panel selection, pixel dimensions
and the behavior of diagonal, ppi and screenRatio.
import SwiftDeviceKitSystem
@MainActor
func readDeviceState() {
let device = Device.current
print(device.systemName ?? "Unknown")
print(device.batteryState?.description ?? "Unavailable")
print(device.thermalState as Any)
print(Device.volumeAvailableCapacity as Any)
}UIKit-backed properties such as battery state, brightness and orientation are accessed on the main actor. Catalog data remains available across concurrency boundaries.
- Migrating from DeviceKit
- Screen specifications
- Adding a device to the catalog
- Testing and optional DeviceKit comparison
- Changelog
MIT. Based on DeviceKit, with the original authors' notices preserved. See attribution.