[英]How to check if an iOS app is running on the simulator. (objective-c)
Is there a way to check if the app is running on the simulator in Runtime?有没有办法在运行时检查应用程序是否在模拟器上运行? I already know how to check at compile time.我已经知道如何在编译时检查。 I want to make sure that the app is running in the simulator at runtime.我想确保应用程序在运行时在模拟器中运行。 (not swift, in Objective-C...) Thank you. (不是 swift,在 Objective-C...)谢谢。
There is no difference between checking in compile/runtime because ios devices and simulators have different architectures - arm64
and x86_64
accordingly and you can NOT run ARM code on the simulator and vice versa.检查编译/运行时没有区别,因为 ios 设备和模拟器具有不同的架构 - arm64
和x86_64
相应地,您不能在模拟器上运行 ARM 代码,反之亦然。 In other words you have two compiled copies of your code which are build for the target platforms.换句话说,您有两个为目标平台构建的代码的编译副本。
To check which one is running you can use the next iOS Simulator SDK flag:要检查哪个正在运行,您可以使用下一个 iOS 模拟器 SDK 标志:
const BOOL IS_SIMULATOR(void) {
#if TARGET_IPHONE_SIMULATOR
return YES;
#else
return NO;
#endif
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.