Main menu Post navigation How to find out if your iPhone app is running in the iPhone Simulator Sometimes it is useful to run different code when your iPhone application is being tested in the iPhone Simulator rather than on a real iPhone or iPod Touch device. For example, if you are testing CoreLocation functionality in the Simulator, all of CoreLocation's returned locations will be for somewhere in Cupertino -- not much use for testing with non-US data. Just to clarify -- my original post suggested checking for __i386__ and forking your code based on whether it is set or not. H pointed out that this is a Bad Idea, so I've updated the post to reflect his much better suggestion instead. Full credit to H for the correction. This code doesn't actually work properly. TARGET_OS_IPHONE also works in the emulator because the iPhone emulator runs the iPhone OS. The only reason this code works in your example is because you're checking for the emulator first. If you checked the device first, your code would fail. Since the first if statement fails, you default to the second which makes it seem like you're on the phone when in fact the second statement is true even when you're running in the emulator. You can test this by making a bunch of #if/#endif statements instead of an #if/#elif/#else/#endif statment.