Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Firebase Analytics Debugview on Testflight

I am unable to view analytics debug view after I install the app through TestFlight into my test phone.

I have passed in argument -FIRDebugEnabled, and have tried -FIRAnalyticsDebugEnabled but no luck.

-FIRDebugEnabled -FIRAnalyticsDebugEnabled

If I directly installed the app into my test phone through Xcode, the debug view will be available. But if it's installed through TestFlight, the debug view cannot be seen.

like image 627
user3135515 Avatar asked Jul 25 '19 02:07

user3135515


2 Answers

Add following code at the first line of application:didFinishLaunchingWithOptions: method of AppDelegate file

CommandLine.arguments.append(contentsOf: ["-FIRDebugEnabled", "-FIRAnalyticsDebugEnabled"])
like image 59
Ibnu Sina Avatar answered Nov 17 '22 16:11

Ibnu Sina


This can be done by injecting special flags into Firebase's local storages. -FIRDebugEnabled command line argument is being checked by both: FirebaseCore and FirebaseAnalytics frameworks. While the former is saving the flag into shared UserDefaults, the latter is using APMUserDefaults private class, which can be accessed in runtime:

if let APMUserDefaults = NSClassFromString("APMUserDefaults") as AnyObject?,
   let userDefaults = APMUserDefaults.perform(#selector(getter: UserDefaults.standard))?.takeUnretainedValue() {
   _ = userDefaults.perform(#selector(NSMutableDictionary.setObject(_:forKey:)),
                            with: true, 
                            with: "/google/measurement/debug_mode")
}
UserDefaults.standard.set(true, forKey: "/google/firebase/debug_mode")
like image 4
Nickolay Tarbayev Avatar answered Nov 17 '22 16:11

Nickolay Tarbayev