Updated. (see comments below)
There may be cases where a certain setting needs to be tweaked based on whether you test on the device or simulator. It took me a while to find the pre-processor directive to detect whether or not the current build targets the iPhone device or the simulator, but with a bit of searching through the GTM code, I found everything I needed in “TargetConditionals.h”. An obvious place, in retrospect, but I wasn’t able to find this information easily elsewhere on the web, so I mention it here in case you find it useful.
Here’s an example of how I’ve used it:
#if TARGET_CPU_ARM#if TARGET_IPHONE_SIMULATOR // Device will hit external server over cell network NSString const *ROOT_URL = @"http://www.external-site.com"; #else // Simulator will hit local server over LAN NSString const *ROOT_URL = @"http://localhost:8667"; #endif
This kind of tweaking is particularly important when the device itself can not participate on the local network, but needs to access some kind of external environment (or proxy server). Conversely, targeting the simulator to use a local ‘development’ server is often faster when deploying and debugging issues in your application, particularly if you are developing the server component in tandem.
Another example involved certain audio playback features which work fine on the device, but run into hiccups running on the simulator. Since in this case the functionality is not critical to test, I ignore it in the simulator.