2

I am developing an App using Firebase Analytics for Swift IOS

pod 'Firebase/Core'

My understanding is that it is not possible to confirm Firebase events are sent in real time unless I use BigQuery which I do not have access to.

For QA purposes I would like to write Firebase logging to a text file rather than to console.

Is it possible to send all output with flag set

-FIRAnalyticsDebugEnabled 

to a text file which could then be more easily checked than using an HTTP Sniffer.

---- Update -----

This is the code I used from Alex's idea, his link did not include Swift 3 solution which has a few updated variables.

func redirectConsoleLogToDocumentFolder() {
    let file = "log.txt"
    if let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
        let logFileURL = dir.appendingPathComponent(file)
        print("log:\(logFileURL)")

        logFileURL.withUnsafeFileSystemRepresentation {
            _ = freopen($0, "a+", stderr)
        }
    }
}
Ryan Heitner
  • 13,119
  • 6
  • 77
  • 119

1 Answers1

1

You can use that flag in development and follow the steps in this post to output to a file.

Community
  • 1
  • 1
adbitx
  • 2,019
  • 8
  • 13