I have been spending some time now, trying to figure out, how to deactivate the logging of events in Firebase Analytics for iOS when running an app in the Xcode simulator.
Currently I have set Firebase up as described in Googles documentation. The issue is that Firebase Analytics seems to log events even when I run my app on Simulator/test device from Xcode. This messes with the statistics that I would see in the Firebase console.
Can anyone help me out with information on how to prevent this behavior?
Thanks in advance!
Here is what I ended up using:
func isRunningLive() -> Bool {
#if targetEnvironment(simulator)
return false
#else
let isRunningTestFlightBeta = (Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt")
let hasEmbeddedMobileProvision = Bundle.main.path(forResource: "embedded", ofType: "mobileprovision") != nil
if (isRunningTestFlightBeta || hasEmbeddedMobileProvision) {
return false
} else {
return true
}
#endif
}
if isRunningLive() {
FirebaseApp.configure()
Analytics.setAnalyticsCollectionEnabled(true)
} else {
FirebaseApp.configure()
Analytics.setAnalyticsCollectionEnabled(false)
}