15

I need to detect at run time whether my apps copy is Production/Development version. Is there any methods to achieve the same.

I am looking forward to develop push notification API which will send APNS messages to server accordingly(i.e. sandbox or without sandbox).

Any help? thanx in advance.

3
  • 1
    you could use schemas, in my applications I have a development and a production schema and a plist file for each one, so you can run in either production or development mode locally Commented Apr 7, 2016 at 11:58
  • 1
    You can add a compilation parameter to each configuration and check that one (Preprocessor Macros, as an example). Commented Apr 7, 2016 at 14:43
  • 2
    stackoverflow.com/questions/26081543/… Commented Apr 7, 2016 at 16:44

1 Answer 1

18

In that case you can use conditional compiling and check if you are in debug mode.

In your project settings you should have defined a preprocessor macro to indicate the debug build:

preprocessor settings

you can use that or define your own.

in your code you can put:

    NSString* platform = @"ios";
#if DEBUG
    platform = @"ios_sandbox";
#endif

everything between #if DEBUG and #endif will only be compiled when DEBUG=1 is defined (in this case only in debug configuration) so at the end you will have in platform variable the value of ios in release builds and ios_sandbox in debug builds.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.