William Entriken
William Entriken

Reputation: 39263

Disable Google Analytics in iOS simulator

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?

Upvotes: 9

Views: 3782

Answers (3)

Bogdan Razvan
Bogdan Razvan

Reputation: 1714

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

Upvotes: 2

user2613441
user2613441

Reputation: 169

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

Upvotes: 11

Andy
Andy

Reputation: 479

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

Upvotes: 15

Related Questions