Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
493 views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...