Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect app is running on simulator or device [duplicate]

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.

like image 482
user1173142 Avatar asked Sep 10 '25 03:09

user1173142


1 Answers

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
like image 69
fulvio Avatar answered Sep 12 '25 18:09

fulvio