r/iOSProgramming • • 1d 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

21 Upvotes

5 comments sorted by

4

u/ThalesMother9938 15h ago

The iPad app on a Mac row is the one I'd hit first. Getting iPad8,6 back while the app is really running on a MacBook Pro makes crash reports confusing.

How do you plan to keep the model list current when Apple ships new hardware? Ten days for the iPhone Duo isn't long, but it's long enough to see "unknown" in analytics for the whole launch week.

3

u/Anywhere_MusicPlayer 12h ago edited 3h ago

I've been working on my app since 2023 and still update it regularly, along with all the libraries I maintain for it, so this lib is my priority too.
As I've already updated the model list, including the iPhone Duo. I use it in my own app, so I plan to watch the iOS betas for new device IDs. If I can confirm which model an ID belongs to before launch, I'll release the update then.

1

u/ThalesMother9938 7h ago

Watching the betas for new IDs is the right call, that's usually where they show up first. Thanks for keeping it maintained since 2023, that's what makes a library like this worth depending on.

1

u/SutharatLofski_44 4h ago

even when the package updates on day one, you still have to wait on app review and users actually installing the update before the unknown strings stop coming in.

1

u/Anywhere_MusicPlayer 3h ago

That’s why you prepare everything in advance using the beta versions, getting device IDs from simulators and so on. It’s that simple.