user1173142 user1173142 - 6 months ago 22
iOS Question

How to detect app is running on simulator or device


Possible Duplicate:

Programmatically detect if app is being run on device or simulator




How can I detect whether my app is running on Simulator or on Device via code.

Answer

Keep in mind UIDevice provides you already with information about the device itself.

[[UIDevice currentDevice] model]

You can also use the following:

TARGET_IPHONE_SIMULATOR tells you if you're in the iPhone simulator.

TARGET_OS_IPHONE tells you that you're working on the iPhone instead of MacOS.

#if TARGET_IPHONE_SIMULATOR

    NSLog(@"Running in Simulator - no app store or giro");

#else

    NSLog(@"Running on the Device");

#endif

and when ONLY interested in the device

#if !(TARGET_IPHONE_SIMULATOR)

    NSLog(@"Running on device");

#endif