2

I know that the device's model name can be retrieved with:

let device: UIDevice = UIDevice.currentDevice()
println("device.model: \(device.model)")

The problem is that this does not work when running in the simulation. The result would be:

device.model: iPhone Simulator

It works on the device but I want to know which device the simulator is simulating.

How can I get the Device model name when running on Simulator?

Pratik Jamariya
  • 810
  • 1
  • 10
  • 35
Sven Bauer
  • 1,619
  • 2
  • 13
  • 22

4 Answers4

8

@jcesarmobile's answer in Swift:

ProcessInfo.processInfo.environment["SIMULATOR_MODEL_IDENTIFIER"]

Returns e.g. iPhone11,2 for iPhone Xs

Patrick Pijnappel
  • 7,317
  • 3
  • 39
  • 39
3

You can get the device model with

NSString * model = [NSString stringWithFormat:@"%s" , getenv("SIMULATOR_MODEL_IDENTIFIER")];
jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
1

You can't. The device model is based on the actual hardware running the iOS SDK, which in the simulator is the computer.

This pod provides easy access to all device models: https://github.com/InderKumarRathore/DeviceUtil

Pauls
  • 2,596
  • 19
  • 19
1

Actually, iPhone simulator is one kind of model like the real device iPhone 3. You can refer the question here UIDevice currentDevice model possible values

Community
  • 1
  • 1
user448228
  • 88
  • 6