0

I've looked at all the code available for determining the device that an app is running on, but how can you tell what device is running in the simulator?

I've never had this issue before because I've always had hardware to test with. Now that the iPhone 6/6+ is out, I only have the 6+, but need to test on the 6 in the simulator. When I use this thread to determine what device I'm running on, all I get is the simulator.

Thanks.

Community
  • 1
  • 1
Michael Gaines
  • 383
  • 3
  • 13
  • What's your goal? Why do you need to know the device? What trait are you unable to determine at runtime? – rmaddy Sep 25 '14 at 17:10
  • What about size classes? This is what they were made for-- – Hyperbole Sep 25 '14 at 17:12
  • See my comment below. This isn't about screen sizes or classes. – Michael Gaines Sep 25 '14 at 18:31
  • @MichaelGaines It would be helpful to update your question instead of scattering the useful information around in comments to answers. Potential answerers are more likely to see the info in the question. – rmaddy Sep 25 '14 at 19:09

1 Answers1

1

Although other comments have a point, you do not really need to know what device you are running on, what you do need to know is, what functionalities do you have available. And even so, if you just want to output this message, it would be wrong to display iPhone 6 instead of Simulator. Just add the correct code for the iPhone 6 model and it should work, not really much that can go wrong here.

But if you still want to support this, I would go with checking hardcoded resolutions for each device. Since programatically there is no difference between 6+ and 6, except for resolution you could use this. But know that Simulator can be virtually any size you pick, so you must have a fallback logic for this.

So the resolutions are (in logic points):

  • 320 x 480 - iPhone 4/4S
  • 320 x 568 - iPhone 5/5C/5S
  • 375 x 667 - iPhone 6
  • 414 x 736 - iPhone 6+

From this you can already see that resolution is really not the best way, as you cannot see the difference between iPhone 5 phones as well as iPhone 4. You can add additional checks to get around this, you can separate iPhone 5S by checking if Touch ID is available or similar. But you will not be able to get around the problem completely.

Legoless
  • 10,942
  • 7
  • 48
  • 68