Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS, detect ad-hoc from code

I want to use a different API url for my iPhone app when I'm debugging or doing an ad-hoc deployment. Is there any way to detect from code (if adhoc) use this Url rather than the default one?

like image 407
Christian Schlensker Avatar asked Aug 31 '11 03:08

Christian Schlensker


1 Answers

There are two ways I can think of:

1.) Conditional Compilation

Since you have to "Archive" the product to distribute the adhoc build, you might as well setup a new config for Archive and leverage the preprocessor.

2.) Alternate default .settings files based on Release/Debug/AdHoc.

Same suggestion as above, but using a .settings file instead of compilation. Personally, I'd recommend this over the conditional compilation because it can be changed (and saved) after deployment if you want to test other environments without redeploying.

EDIT

Conditional Compilation refers to using "ifdef" blocks right? I tried this once but couldn't get it to check for AD-HOC, only DEBUG seemed to work

Correct.

There is not an "ADHOC" macro defined by default. But you can easily add one.

Here's how you might go about setting up an additional configuration with a new preprocessor macro for your ADHOC builds:

Step 1: Setup a new Config (optional... you might just use Release... up to you).

Setup a new config

Step 2: Add the preprocessor macro for that config. In my screenshot it only shows Debug and Release because I didn't actually add a new config. If you added a new Config (and called it something like "AdHoc", it should show up here as well:

enter image description here

Add ADHOC=1 just like the DEBUG=1 macro for the debug config.

Step 3: Either modify your current Scheme, or duplicate it, such that the "Archive" step uses your new configuration:

enter image description here

like image 122
Steve Avatar answered Nov 04 '22 01:11

Steve