How to detect an iPhone X

The iPhone X is like a “glimpse into the future”, according to Apple. By “the future” they mean “this is what three year old Samsung components could look like if they ran iOS”. iPhone X has been described as gimmicky and as “$1k for Face ID, with no other benefits”.

Overall it was not as warmly received as the 10 year anniversary device as it perhaps could have been.

But all that aside, as developers, we still need to support it and perhaps even give the device some unique treatment, be that with a dedicated Storyboard to make use of the larger screen, or to give attention to a feature other phones don’t have. Before we can do that though, we need to figure out a way to test if we’re actually dealing with an iPhone X device.

I know of no better way to do this than the trusted screen height check. Let’s see how this might work.

Now all we need to know is the screen height of an iPhone X, and perhaps other supported devices, so we can make an educated decision about what device we’re working with. We can then use this information to give each iPhone model some unique treatment (for example, by loading dedicated storyboards).

We could go one step further and see if we’re perhaps dealing with an iPad, and figure out what type of iPad, but since I’ve covered that in a previous article I won’t repeat myself here. I’m sure you get the picture.

This method, or a decision process like this is best suited for the AppDelegate.m file or another central class. I hope this helps you get started on the journey of discovering The Future on iPhone X (queue spooky futuristic music).