is it possible to route all the NSLog calls from our iOS app and private frameworks into a single file easily.
Like redefining NSLog to something else ?
is it possible to route all the NSLog calls from our iOS app and private frameworks into a single file easily.
Like redefining NSLog to something else ?
I translated this answer to Swift for you. Call this function in your didFinishLaunchingWithOptions
in AppDelegate.
func redirectConsoleLogToDocumentFolder() {
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).map(\.path)
let documentsDirectory = paths[0]
let logPath = URL(fileURLWithPath: documentsDirectory).appendingPathComponent("console.log").path
freopen(logPath, "a+", stderr)
}
This is the path to the console.log
file on iOS devices: /var/mobile/Containers/Data/Application/<your-app>/Documents/console.log