Search code examples
objective-cbuild-process

Different Builds for Simulator and iPhone


The app that I'm working on has a URL that it accesses for data, this URL is defined as a constant as follows:

#define kURLToSendRequestsTo @"http://www.localhost.com/dataAccess.php"

However, this URL will only work for the simulator. For the iPhone I have to change the URL to a test site manually.

What I need is a way to change it dynamically so I don't have to manually change it each time. Something like this:

#if iPhone

#define kURLToSendRequestsTo @"http://www.localhost.com/dataAccess.php"

#elseif simulator

#define kURLToSendRequestsTo @"http://www.testsite.com/dataAccess.php"

#endif

Solution

  • The constants you want are:

    TARGET_IPHONE_SIMULATOR
    

    and:

    TARGET_OS_IPHONE
    

    Reference.