iOS.Device.generation always 'Unknown' in the Xcode simulator

Xcode version 9.2
Unity version 2017.2.0p4

I need to tweak some UI elements for that lovely iPhone X notch :roll_eyes:. When running in the Xcode simulator, the value for UnityEngine.iOS.Device.generation is always “Unknown”. I’ve tried multiple devices and iOS versions to confirm.

When running a test build on an actual device, the value is correct.

Is this a bug with Unity or a limitation of the iOS simulator?

Might try the iOS subforum on here Unity Engine - Unity Discussions as you may have better luck. (I don’t do iOS builds, so I have no advice on the simulator)

But it’s very possible it’s just how the simulator is. I know that many times things don’t always behave the way we expect unless it’s built to a real device.

Yes, same problem. It doesn’t seem to work on simulator. Have to try on a real device yet… will keep you posted if it works!

UPDATE: Doesn’t work for me on the device either

Have the same problem, just released an update where the app supposedly “support iPhone X”, but it doesn’t, because of this bug our UI is messed up.

@Mantas-Puida any insight to what Unity-release will fix this?

I’m seeing this same problem on the simulator with Unity 2017.3.1p3 Does this also happen on the actual device?

My workaround for this is to test UnityEngine.iOS.Device.generation - if it’s Unknown, then fallback to testing the screen aspect ratio. If it’s < 0.5, I assume iPhone X (Simulator). Hacky, I’ll admit, but works.