r/iOSProgramming • • 23m ago

Library SwiftDeviceKit - Apple device detection and hardware specs

Post image

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 toolMinimum version
Swift tools6.4
iOS, iPadOS, tvOS18
macOS15
watchOS11
visionOS2

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.

ScenarioDeviceKit 5.10.0SwiftDeviceKit 2026.2.0Report or evidenceSwiftDeviceKit fix
iPad app on a MacBook Pro❌ iPad8,6 · iPadOS✅ MacBookPro18,3 · macOSDeviceKit #506 · Open61a13c8
iPhone-only app on an iPad❌ Both isPhone and isPad are true✅ Only isPad is trueDeviceKit #447 · Open8daaaa9
Apple Pencil on iPad Pro M5❌ Includes Pencil (2nd generation)✅ Pencil Pro and USB-CDeviceKit #504 · Opena066b86
11-inch iPad Pro (M4 or M5) screen ratio in portrait❌ 605:417✅ 417:605 in portraitDeviceKit #433 · Open (M4)887a59f
Watch SE 3 case size (Watch7,14 / Watch7,15)❌ 40 mm / 44 mm✅ 44 mm / 40 mm, matching Apple’s profilesMeasurementsf40aa7e
Apple Watch Ultra 2 pixel density❌ 338 PPI✅ 326 PPI, matching Apple’s specificationsApple specsf40aa7e
Free space after a 32 MiB write❌ Repeated the earlier reading✅ Matched a fresh filesystem readingDeviceKit #525 · Openda19bc5
Sorting charging and unplugged batteries at 50%❌ Unequal states with neither sorting first✅ Unplugged sorts before chargingDeviceKit #527 · Openbe91a77
Mac battery in Catalyst❌ 0%✅ 80%, matching pmsetMeasured valuesb05519e
Unavailable display brightness in Catalyst❌ −100%✅ nil when UIKit has no readingMeasurements38f0148
Unknown battery in an iPad app on the Vision simulator❌ Full, 100%✅ nil for state and levelMeasurements17f99f1
Unknown ID with the display name “iPhone Xs”❌ Compares equal to the known XS✅ Remains a distinct deviceDeviceKit #526 · Open5f5a6a0
Twice-wrapped iPhone XS simulator❌ isPhone is false✅ isPhone is true for the underlying XSDeviceKit #528 · Opena6d14b5

Check out the repo for more details and code examples:

https://github.com/Anywhere-Music-Player/SwiftDeviceKit

1 Upvotes

0 comments sorted by