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.
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.
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
You can use this constant
#if TARGET_OS_SIMULATOR
NSLog(@"This is simulator mode....");
#else
NSLog(@"This is device mode....");
#endif
The same compiled app cannot run on both the Simulator and an iOS device, as the CPU instructions sets are completely different (x86 vs. ARM). (...unless you are building some sort of very strange super-universal binary using lipo)
There are several ways to determine whether the app was compiled for x86 or not. One is to add run time code the differs depending on one of the many predefined compiler preprocessor macros. You can get a list of preprocessor macros for an x86 compile by typing this on the Terminal command line:
gcc -arch i386 -dM -E - < /dev/null | sort