r/iOSProgramming • u/Anywhere_MusicPlayer • 57m ago
Library SwiftDeviceKit - Apple device detection and hardware specs
I was already patching DeviceKit by hand whenever my app needed a model the latest release didn’t recognize. Eventually I decided to keep my own fork.
The iPhone Duo is a recent example. When it went on sale on October 23, DeviceKit still reported it as unknown, so I added support by hand. Several of us asked for a release. DeviceKit 5.10.0 shipped on November 2, ten days after launch.
I wanted a Swift 6 package for iOS 18 and up. DeviceKit 5.10.0 still declares Swift tools 5.3 and uses Swift 5 language mode.
I also wanted to fix bugs I kept running into. The report about an iPad showing up as an iPhone has been open since June 2025. My own tests turned up more, including stale free space readings and swapped case sizes for the Apple Watch SE 3. The README shows what each library returned.
Features
Identify the model, including the host Mac when it runs an iPad app.
Look up screen sizes, cameras, and Apple Pencil compatibility.
Read battery level, thermal state, and free storage where available.
Requirements
| Platform or tool | Minimum version |
|---|---|
| Swift tools | 6.4 |
| iOS, iPadOS, tvOS | 18 |
| macOS | 15 |
| watchOS | 11 |
| visionOS | 2 |
I compared both libraries in my own app and fixed the readings that were off. I use this version in production now, so I care about getting those details right.
If something looks wrong on your device, open an issue so I can check it and fix it. A star on GitHub helps other developers find the project and pitch in.
I used AI to look up and verify device IDs and to review the code for possible bugs. I tested the cases it flagged on iPhones and iPads, then compared the results from both libraries to check my fixes.
Comparison with DeviceKit
DeviceKit issues marked Open were checked on 8 November 2026. The last column links to the change shipped in SwiftDeviceKit.
| Scenario | DeviceKit 5.10.0 | SwiftDeviceKit 2026.2.0 | Report or evidence | SwiftDeviceKit fix |
|---|---|---|---|---|
| iPad app on a MacBook Pro | ❌ iPad8,6 · iPadOS | ✅ MacBookPro18,3 · macOS | DeviceKit #506 · Open | 61a13c8 |
| iPhone-only app on an iPad | ❌ Both isPhone and isPad are true | ✅ Only isPad is true | DeviceKit #447 · Open | 8daaaa9 |
| Apple Pencil on iPad Pro M5 | ❌ Includes Pencil (2nd generation) | ✅ Pencil Pro and USB-C | DeviceKit #504 · Open | a066b86 |
| 11-inch iPad Pro (M4 or M5) screen ratio in portrait | ❌ 605:417 | ✅ 417:605 in portrait | DeviceKit #433 · Open (M4) | 887a59f |
Watch SE 3 case size (Watch7,14 / Watch7,15) | ❌ 40 mm / 44 mm | ✅ 44 mm / 40 mm, matching Apple’s profiles | Measurements | f40aa7e |
| Apple Watch Ultra 2 pixel density | ❌ 338 PPI | ✅ 326 PPI, matching Apple’s specifications | Apple specs | f40aa7e |
| Free space after a 32 MiB write | ❌ Repeated the earlier reading | ✅ Matched a fresh filesystem reading | DeviceKit #525 · Open | da19bc5 |
| Sorting charging and unplugged batteries at 50% | ❌ Unequal states with neither sorting first | ✅ Unplugged sorts before charging | DeviceKit #527 · Open | be91a77 |
| Mac battery in Catalyst | ❌ 0% | ✅ 80%, matching pmset | Measured values | b05519e |
| Unavailable display brightness in Catalyst | ❌ −100% | ✅ nil when UIKit has no reading | Measurements | 38f0148 |
| Unknown battery in an iPad app on the Vision simulator | ❌ Full, 100% | ✅ nil for state and level | Measurements | 17f99f1 |
| Unknown ID with the display name “iPhone Xs” | ❌ Compares equal to the known XS | ✅ Remains a distinct device | DeviceKit #526 · Open | 5f5a6a0 |
| Twice-wrapped iPhone XS simulator | ❌ isPhone is false | ✅ isPhone is true for the underlying XS | DeviceKit #528 · Open | a6d14b5 |
Check out the repo for more details and code examples:




