简体   繁体   中英

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.

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. 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:

const BOOL IS_SIMULATOR(void) {
#if TARGET_IPHONE_SIMULATOR
    return YES;
#else
    return NO;
#endif
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM