Closed bzarco closed 2 years ago
Thanks for this!
I was also inclined towards something like this as a workaround. Let me try this and a couple of other things to satisfy my curiosity. Overall looks good, I'll try to have a detailed look tomorrow. Thanks again!
This still doesn't work for me. I tried playing around some more, and looks like all --stdout/stderr
, --console
and --console-pty
are not working as expected when debugger is attached. I also tried launching from command line with --wait-for-debugger --console-pty
and then attaching from vscode, no logs printed in terminal.
It almost seems like when the debugger is attached, the logs are somehow redirected somewhere else and seems to never reach stderr/stdout. Without the debugger atttached, all of these options work as expected for me.
I'm on Version 13.3.1 (13E500a), in case that is making any difference.
I am on version 13.4 (13F17a), but I doubt that makes a difference? --console
and --stdout/stderr
don't work for me, only --console-pty
(tried both in the terminal and attached to debugger). As mentioned in the issue I am using print
in Swift, which seems like it makes a difference. With this change the experience is consistent with device debugging, at least in my experience. Does this work for you if you use fprintf
instead of NSLog
?
Thanks a lot for helping out with this! :)
Happy to help!
Strange this doesn't seem to work for me.
Tailing /tmp/ios-2ccba12602b3620ec5a2c015bc9ff94f-stdout
Tailing /tmp/ios-2ccba12602b3620ec5a2c015bc9ff94f-stderr
Attached to process 6096
No output from my SwiftUI view:
.onAppear(perform: {
print("On Appear")
Logging().trylog()
})
Fixes #3.
It seems that
simctl launch --stdout=* ...
doesn't work anymore, it creates the file but doesn't pipe the output. To fix this, this change launches the app using spawn and pipes sdout/stderr to the files.Unfortunately simctl buffers printing the pid (it is not printed until the process terminates), so we need to poll for the pid. An alternative would be to spawn using pty (using
node-pty
), or use something likestdbuf
/unbuffer
to runsimctl
, but that seems more complex than necessary.