1

Is there a way to know if the program is running in the development environment? I'm using Flurry Analytics and want to pass it a different app id, so the data doesn't get dirty with my tests during development.

What I'd like is something like this:

Boolean isDevEnv = .... (is this a test in the simulator or device,
                         OR is it a real user that downloaded the 
                         app through the app store?)
if (isDevEnv)
  [FlurryAnalytics startSession:@"firstAppId"];
else
  [FlurryAnalytics startSession:@"secondAppId"];

To be clear, this is not what I'm after, because I test using a real device as well as the simulator.

Community
  • 1
  • 1
cambraca
  • 27,014
  • 16
  • 68
  • 99

4 Answers4

2

In the build settings you'll have to set flags, depending on the building env.

Then, use #ifdef and #define to set the appid.

#ifdef DEBUG
#    define APPID ...    
#else
#    define APPID ...
#endif
Brice
  • 1,026
  • 9
  • 20
  • I'm probably doing something stupid wrong: in Targets, I select the only one, then go to the Build Settings tab, then Add Build Setting, which adds a row in the User-Defined group (I named it "TESTING"), then for each one (Debug and Release) I click on the plus sign, what values do I put there? – cambraca May 25 '12 at 16:08
0

In your build settings, define a new flag for the App Store release version. Then use #ifdef to determine at compile time which appid to use.

jrtc27
  • 8,496
  • 3
  • 36
  • 68
0

if you don't want to use DEBUG flag and DEBUG environment, create a new build configuration (duplicate Release configuration) and in the build settings Preprocessor Macros add a FlurryAnalytics flag. In your code check if(FlurryAnalytics). Create a new scheme in XCode that creates ipa using this new release build configuration.

0x8badf00d
  • 6,391
  • 3
  • 35
  • 68
0

Well, it seems this is done by default by Xode, in the Project's Build Settings, under Apple LLVM compiler 3.1 - Preprocessing (this is in Xcode 4.3.2, for future reference), a setting called DEBUG is populated with the value 1.

So, I didn't really have to do anything, just this in the code (in my case in the AppDelegate's didFinishLaunchingWithOptions method):

[FlurryAnalytics startSession:DEBUG ? @"firstAppId" : @"secondAppId"];
cambraca
  • 27,014
  • 16
  • 68
  • 99