9

Google Analytics is running in the iOS simulator.

This causes pollution in the console log which I can be looking for useful debugging information. Also, the data sent to Google is not indicative of an actual user using our app.

How can I disable the Google Analytics reporting just while running the app in iOS simulator?

William Entriken
  • 37,208
  • 23
  • 149
  • 195

3 Answers3

15

Simple, this is taken straight from the Google Analytics webpage :

[[GAI sharedInstance] setDryRun:YES];

Dry Run :
The SDK provides a dryRun flag that when set, prevents any data from being sent to Google Analytics. The dryRun flag should be set whenever you are testing or debugging an implementation and do not want test data to appear in your Google Analytics reports.

Hope this helps

Andy
  • 479
  • 7
  • 20
11

Yes, Setting DryRun to YES will fix this issue.

@Full Decent - Is there a way to also not have Google Analytics pollute my console logs?

We can disable Google Analytics logging in Xcode console using the below method.

[[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelNone];

Or in Swift:

GAI.sharedInstance().logger.logLevel = GAILogLevel.None

Christopher Hackett
  • 6,042
  • 2
  • 31
  • 41
user2613441
  • 169
  • 2
  • 7
2

Wrapping it in #if TARGET_IPHONE_SIMULATOR #endif will not work in swift, as that flag is for objective-c only. What you could do is follow this guide

Detect if app is being built for device or simulator in Swift

Bogdan Razvan
  • 1,497
  • 1
  • 16
  • 16