the printout on the Xcode console log is not showing in the "idevicesyslog" from libimobiledevice

I have an iOS application which is developed with C++, and my physical iPhone is connected to my Mac. While running the app via Xcode, I can easily view the printouts within the Xcode console. However, upon manually executing the app on the iPhone and utilizing the command "idevicesyslog -d -p myAppName" on my Mac the terminal, I notice that only specific logs generated by the .mm files are visible. And I'm unable to access the remaining traces, macros, and other details from the .h or .cpp files.

Is there a method to ensure that all the logs I observe in the Xcode console are also displayed in "idevicesyslog"? Alternatively, are there any technique to show all the printout from .cpp and .h files.

I can’t help you with idevicesyslog. Based on a quick ’net search, I suspect it’s running on very shaky foundations; there are no supported APIs to do what it’s doing. Regardless, questions about its behaviour are best directed to its support channel.

In terms of monitoring output from an app running on an attached iPhone — assuming that you’ve run your app from the Home screen and not from Xcode — there are two cases to consider:

  • System log entries, generated by the system log API

  • Stuff printed with to stdout or stderr

To monitor the system log of an attached device, run the Console utility and select the device on the left. For a bunch more info about the system log, see Your Friend the System Log.

There’s no good way to monitor stdout and stderr of an app run from the Home screen. When you run the app from Xcode, it’s able to hook stdout and stderr via its debugging infrastructure, but there’s no way to do that otherwise.

The best option here is to update your C++ code to log to the system log.

If you can’t do that, you could probably get something working with some low-level Unix-y shenanigans. When you launch your app from the Home screen its stdout and stderr point to /dev/null. You could use dup2 to replace that with, say, a pipe, and then monitor the other end of the pipe and forward the output to a place of your choosing.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

In the end goal I would like to fetch the logs programmatically, and then grabbing the content of logs for some analysis. I wonder if it is enough to use

sudo log collect --predicate 'process == "com.example.myapp"' --device-udid 83yiphoneuuid464946464

I wonder if it is enough to use

log collect is a fine feature, one that I rely on extensively. However, it’ll only catch system log entries. If your C++ code is printing to stdout or stderr, it won’t see that output. I see two ways around that:

  • Change your C++ code to log via a macro. You can then define the macro to log to the system log when necessary.

  • Redirect stdout and stderr to something custom, per my previous reply.

One nice thing about log collect is that you can use log show to convert the log to a machine readable format, using --style with either json or ndjson, and then build a custom tool to manipulate the results.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

the printout on the Xcode console log is not showing in the "idevicesyslog" from libimobiledevice
 
 
Q