xcode - Dectect what flavor of iOS the simulator is running - Stack Overflow

Most answers on SO seem to want to know how to detect if the simulator is running.I know that it is.I

Most answers on SO seem to want to know how to detect if the simulator is running.
I know that it is.

I want to determine what device the simulator is simulating?
I want to read something like "I am simulating an iPhone 15 Pro Max (for example)"

How do I do this? Where can I find this data?

Most answers on SO seem to want to know how to detect if the simulator is running.
I know that it is.

I want to determine what device the simulator is simulating?
I want to read something like "I am simulating an iPhone 15 Pro Max (for example)"

How do I do this? Where can I find this data?

Share Improve this question asked Feb 23 at 12:44 DefenestrationDayDefenestrationDay 3,8622 gold badges37 silver badges65 bronze badges 1
  • Is this something you want from your running app or just by looking at the simulator? Simply look at the simulator window title to see the device and iOS version. – HangarRash Commented Feb 23 at 18:06
Add a comment  | 

1 Answer 1

Reset to default 3

You can use this:

let str = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"]

to get the model string in this format:

"iPhone14,6"
...
"iPhone16,1"
...
"iPad13,8"
...
etc

and so on... and you'd commonly use a Model lookup table to get the "friendly" name.

You can also use this:

let str = ProcessInfo().environment["SIMULATOR_DEVICE_NAME"]

which returns:

"iPhone SE (3rd generation)"
...
"iPhone 15 Pro"
...
"iPad Pro (11-inch) (4th generation)"
...
etc

without the need for the lookup table.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745154794a4614051.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信