go-ios
go-ios copied to clipboard
Be able to get the main app logs when use ios test command
Currently, when we use the "ios test" command line we can see the logs of the test but we cannot see the log of the mainapp.
XCUITests run as a separate target with an additional proxy application installed on the device. If you run an XCUITest through Xcode you will get only the logs of the test as well and not the logs of the targeted application. IMHO we shouldn't print application logs while running XCUITest with ios runtest even if we have that possibility
The application logs are output into the syslog for regular apps. So you can use go-ios syslog to view those.
For application extensions I haven't seen any reliable mechanism to get their logs thus far.
XCUITests run as a separate target with an additional proxy application installed on the device. If you run an XCUITest through Xcode you will get only the logs of the test as well and not the logs of the targeted application. IMHO we shouldn't print application logs while running XCUITest with
ios runtesteven if we have that possibility
When we use xcode to run the test we have access to the both (UITest and MainApp) logs
The application logs are output into the syslog for regular apps. So you can use go-ios syslog to view those.
For application extensions I haven't seen any reliable mechanism to get their logs thus far.
So you think that xcode use the syslog to get the app logs?
I've studied the lockdown protocol extensively.
There are two different ways to access the syslog:
- Get the entire syslog streaming ( this is what go-ios is doing )
- Request syslog for only a specific process ( iosif does this, go-ios does not yet support it )
I don't think that Xcode uses syslog to get the app logs. I know that it does, through mechanism 2.
You just have to add some env vars to the app process and it will log its logs via instruments. I hacked a first version here: https://github.com/danielpaulus/go-ios/pull/205 Will clean it up and make it a little more usable.
Cleaned it up for the launch command. It does not work yet with XCTest, I am missing probably some stuff in the xctest config. Will check that soon and add it to the PR.
Oh seems like I was wrong. Xcode does not print out the app under tests' logs if release mode. Go-iOS is based on release mode commands and does not use the debugger to connect to apps. I haven't played much with lldb also it is certainly interesting. I could try using syslog or the instruments logging next.
@CedricCouton after reading this: https://stevenpcurtis.medium.com/logging-in-swift-d9b59146ff00 It seems like print only goes to the stdout of the app while NSLog and os_log are also going the the system log. I wonder, what are developers normally using? I will see if I can figure out how XCode uses the debugger to get the stdout of the app.
Hi @nanoscopic and @danielpaulus. I had a similar (and somehow related) question. Is there a way to save the output of the tests, whilst using the "runtest" command? I can see the test outputs (not the device logs, which is obtainable using syslog) on the console when test is being run, but if I need to export the logs as well. I know we can write the logs to a file (either from the command line, OR write the output to a file in Go), but I was wondering if there's an option we can pass (perhaps an entry in the env file? 🤷🏻♂️) so that I don't reinvent anything :)
Thanks a lot and if anything please let me know :)
EDIT: If you think this is worthy of another issue, please let me know and I'll create it.