How to use different URLs for Simulator and Device
<p>I am building a Web application.</p>

<p>When I am testing it on a simulator, I want to typically use a local loop back URL e.g. localhost because the test may mess up the data on a real server. When I want to test/release on a Device, I want to use a real server.</p>

<p>I can change the value manually, of course, but it is easy to forget to change. I am looking for an automatic solution if it is possible.</p>

<p>E.g. if I am using Debug or just Run, I know that I could use DEBUG flag that is set by the Project settings to produce different codes.</p>

<p>i.e.</p>

<pre><code>#ifdef DEBUG
    kURL = @"http://localhost/xyx"
#else
    kURL = @"http://realserver/xyz"
#endif
</code></pre>

<p>Since the flag is automatically set by the Xcode (I still choose whether to Run or Debug from the Menu), it relieves me from manually setting the flag in the code myself regarding whether it is run for Debug or Run.</p>

<p>Although this is useful, the DEBUG flag is no use to detect either it is run on a simulator or on a device.</p>

<p>I don't know whether there is any flag defined to identify whether it is running on a simulator or a device (or different versions/names of SDKs, since it seems that they use different SDKs), that I could use to instruct the code to use different URLs. </p>

<p>Any idea?</p>

<p>Thanks.</p>
