How can I get a console readout at runtime in an application?

后端 未结 2 1038
栀梦
栀梦 2020-12-08 08:39

For debugging purposes, I\'d like to access console printouts at runtime in a way similar to the Console app current on the App Store (that can be found here).

I did

2条回答
  •  情书的邮戳
    2020-12-08 09:22

    If your device is attached to Xcode, you can see console output (NSLogs and such) in the debug area:

    If you're running the app and connecting to Xcode later, I believe you can get console logs in the Organizer.


    Edit: to access the log file at runtime, you should try /var/log/system.log — but even better I recommend using a custom debug function, which would write to the system log and/or a text view in your app. (Check out NSLogv, which will be useful when writing a wrapper function.) This also has the advantage of letting you disable all debug logs from one place (just change your debug function).

提交回复
热议问题