Disable Google Analytics in iOS Simulator

Google Analytics runs in the iOS simulator.

This causes pollution in the console log, and I can find useful information for debugging. In addition, data sent to Google does not indicate the actual user using our application.

How to disable the Google Analytics report only when the application starts in the iOS simulator?

+7
ios google-analytics
source share
3 answers

Simple, this is taken directly from the Google Analytics web page:

[[GAI sharedInstance] setDryRun:YES]; 

Dry running:
The SDK provides the dryRun flag, which during installation prohibits the sending of any data to Google Analytics. The dryRun flag must be set whenever you test or debug an implementation and do not want the test data to be displayed in Google Analytics reports.

Hope this helps

+12
source share

Yes, installing DryRun on YES will fix this problem.

@Full Worthy - is there any way to prevent Google Analytics from polluting my console logs?

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

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

Or in Swift:

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

+11
source share

The wrapper in #if TARGET_IPHONE_SIMULATOR #endif will not work quickly because this flag is for objective-c only . What you can do follow this guide.

Detect if an application is being created for a device or simulator in Swift

+2
source share

All Articles