最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论