Xcode 错误地 "recognizing" iOS 模拟器作为实际设备
Xcode incorrectly "recognizing" iOS Simulator as actual Device
我正在使用相机并想检查我是在使用 iOS 模拟器还是实际设备,所以我将此语句放入我的代码中:
#if IOS_SIMULATOR
print("It's an iOS Simulator")
#else
print("It's a device")
#endif
然而,当我 运行 设备在 iOS 模拟器中时,它实际上打印出 "It's a device"。
相反。我可以检查一下其他 Xcode 设置或标志吗?
好像我会选择一些东西说 "Even if it's the Simulator always run as if it's a device" 你知道吗?
我不确定您从哪里得到 IOS_SIMULATOR,但它肯定不是来自 Apple。我建议您使用 Apple 的 API 来执行此操作。例如:
#include <TargetConditionals.h>
#if TARGET_OS_SIMULATOR
...
#else
...
#endif
我正在使用相机并想检查我是在使用 iOS 模拟器还是实际设备,所以我将此语句放入我的代码中:
#if IOS_SIMULATOR
print("It's an iOS Simulator")
#else
print("It's a device")
#endif
然而,当我 运行 设备在 iOS 模拟器中时,它实际上打印出 "It's a device"。
相反。我可以检查一下其他 Xcode 设置或标志吗?
好像我会选择一些东西说 "Even if it's the Simulator always run as if it's a device" 你知道吗?
我不确定您从哪里得到 IOS_SIMULATOR,但它肯定不是来自 Apple。我建议您使用 Apple 的 API 来执行此操作。例如:
#include <TargetConditionals.h>
#if TARGET_OS_SIMULATOR
...
#else
...
#endif