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.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
vje1998
  • 691
  • 6
  • 19
  • 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 – Scriptable Apr 07 '16 at 11:58
  • 1
    You can add a compilation parameter to each configuration and check that one (Preprocessor Macros, as an example). – lucianoenrico Apr 07 '16 at 14:43
  • 2
    http://stackoverflow.com/questions/26081543/how-to-tell-at-runtime-whether-an-ios-app-is-running-through-a-testflight-beta-i – jithin Apr 07 '16 at 16:44

1 Answers1

19

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.

Jorge Arimany
  • 5,814
  • 2
  • 28
  • 23