I have snapshot tests which are per device. I want to check in my tests that I am running on a particular simulator that has a snapshot for it.
So for example I want to test that current simulator is iPhone6sPlus9.2 since the snapshot wasn't recorded for the many other simulator types I have.
I've tried many variations like:
(lldb) po [[UIDevice currentDevice] platform]
x86_64
(lldb) po [[UIDevice currentDevice] hwmodel]
MacBookPro11,2
(lldb) po [[UIDevice currentDevice] platformType]
0x0000000000000002
(lldb) po [[UIDevice currentDevice] platformString]
iPhone Simulator
(lldb) po [[UIDevice currentDevice] model]
iPhone
(lldb) po [[UIDevice currentDevice] localizedModel]
iPhone
(lldb) po [[UIDevice currentDevice] systemName]
iPhone OS
(lldb) po [[UIDevice currentDevice] systemVersion]
9.2
(lldb) po [UIDevice currentDevice]
<UIDevice: 0x7fccf060a480>
(lldb) po [[UIDevice currentDevice] name]
iPhone Simulator // I WANT TO KNOW THAT IT IS IPHONE6SPLUS 9.2
and also the code from here https://github.com/erica/uidevice-extension/
and the code from
// UIDevice+YYAdd.h // YYKit https://github.com/ibireme/YYKit
but both are returning irrelevant values such as "x86" for the device type.
Try
[NSProcessInfo processInfo].environment[@"SIMULATOR_MODEL_IDENTIFIER"]
It will return
iPhone8,2
for the iPhone6s Plus Simulator.Attention: You may have your reasons to write code against a specific simulator model, but it's generally not a good idea. You should instead dynamically adapt screen sizes, check the availability of APIs / Frameworks and so on...