Reputation: 11
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.
Upvotes: 0
Views: 2067
Reputation: 13758
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
}
Upvotes: 3