Firebase Analytics Debug Mode + BuddyBuild

2.2k views Asked by At

In order to enable Firebase Analytics Debug Mode we need to add this flag

-FIRAnalyticsDebugEnabled

to Xcode as described in the official documentation.

enter image description here

However...

... this only works when we launch the app from Xcode. When we deploy the app via BuddyBuild the argument is lost.

My question

How can I enable Firebase Analytics Debug Mode when the app is deployed via BuddyBuild?

3

There are 3 answers

0
Romain Pouclet On BEST ANSWER

That's indeed not possible with buddybuild. Even with a shared scheme, the arguments passed on launch are set by iOS once you run the app from a device.

Unfortunately, there doesn't seem to be a way to decrease the refresh rate, which I assume was your goal.

0
adbitx On

This is designed so that you can't ship the Debug Mode with the app because it will spam the system log and send debug traffic.

0
Alex On

⚠️☢️ Be careful. make sure you DON'T use this code in PRODUCTION builds.

Here is an extension that swizzles arguments property of ProcessInfo class

extension ProcessInfo {
    @objc dynamic func swizzled_arguments() -> [String] {
        self.swizzled_arguments() + Self.additionalArguments
    }

    static var additionalArguments: [String] = [] {
        willSet {
            swizzleArgumentsProperty
        }
    }

    static let swizzleArgumentsProperty: Void = {
        let originalGetter = class_getInstanceMethod(ProcessInfo.self, #selector(getter: arguments))
        let swizzledGetter = class_getInstanceMethod(ProcessInfo.self, #selector(swizzled_arguments))
        method_exchangeImplementations(originalGetter!, swizzledGetter!)
    }()
}
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
/// ...
    ProcessInfo.additionalArguments.append("-FIRAnalyticsDebugEnabled")
    ProcessInfo.additionalArguments.append("-FIRDebugEnabled")

    FirebaseApp.configure()
/// ...
}

I hope it will help somebody.