How to test which iOS Hardware your app is running on

There are two ways to test which hardware your app is currently running on: compiler time and runtime. Both have their advantages.


Here’s how we can check both:

Compile Time Device Check

We can use the currentDevice method of our UIDevice class:

This will give you a string such as “iPhone”, “iPad” or “iPod Touch”.

Runtime Device Check

This is slightly more complex, but I’m sure you’ve heard of identifiers such as “iPhone6,1” or “iPad 3,3” – that’s Apple’s internal numbering system for iOS devices. With this check we can get very fine grained information about the hardware capabilities a device will have.

To use it, we need to first import the sysctrl framework into our app like so:

Then we can use some C methods that reads out this magic identifier. Here’s how:

First we grab the string of this magic identifier, then we compare it to a LONG list of possible values and extract the model number. The list above is not complete and it’s just meant for demo purposes. You get the idea.

The sysctrl functions are documented here:

Demo Project

I have a working demo project on GitHub which has a (relatively complete) list of current iOS device models. Check it out here:

Kudos to the following links that made this possible:

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

2 thoughts on “How to test which iOS Hardware your app is running on

  1. Hi Jay,

    I had a question that i will just drop here:

    Could the query of the “hw.machine” flag cause the rejection of an App in the App Store?



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.