xcode UITests 检查测试是否在真实设备上 运行

xcode UITests check if the test is running on real devices

Xcode 版本 8.2 (8C38)

有没有办法检测 UITests 在真实设备上是否 运行?

谢谢

您可以从 ProcessInfo class:

中获取此信息
if let simulatorName = ProcessInfo.processInfo.environment["SIMULATOR_DEVICE_NAME"] {
    print("Running on \(simulatorName) simulator")
} else {
    print("Running on device")
}