-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tail logs after running #76
base: main
Are you sure you want to change the base?
Conversation
Right now, we're just printing the pid for the app process after running. That's not particularly useful, and I often find myself needing to open Xcode just to use the app in the simulator. I think there's more we could do here, but for right now, it probably makes sense to at _least_ tail the logs for the simulator wherever we ran the run command. It's at least a more useful default behavior than doing nothing.
Hi @gfontenot, override func viewDidLoad() {
super.viewDidLoad()
print("something")
} |
Oh, right, I forgot about that. Maybe this isn't what we want to do. I wonder if it'd be a better default to run an lldb session. |
I think this PR and #77 are both going to be awesome, but I think we might want to move some of this logic into the vim plugin instead. That way we could have much easier hooks around what to do in these cases. We talked about having this entire integration part in a separate plugin, which I'm not sure makes sense anymore, but I do think it would be nice to be able to customize this the way I wanted to, as far as running them in tmux splits, windows etc. |
On the lldb idea here, when launching a process you can pass
We would need both of these if for nothing else that Swift's In theory after setting this up we could tail both at once:
|
I believe this is similar to what Xcode does, as the |
Also just noticed |
So if you change this line:
To
Then the process will launch, seemingly frozen in the foreground of the simulator, and if you then attach a debugger (it seems like there is a timeout for this part too) with something like:
It launches! |
Another possible thing we might able to utilize here is the |
Hmm. So this variable is definitely for this use case, but it seems like setting it after the process is launched, has no effect. Which is kind of our case, since simctl is doing the actual spawning. There must be a way to force a refresh of these file descriptors, but I currently only see that in the python bridge with |
@keith Yeah I did a bunch of experimentation around FWIW, Xcode exhibits this same behaviour when you attach to an app that's already running in the simulator (you don't see stdout/stderr for that process). This makes me think that launching within lldb might be the way to go. |
One possible solution to this would be instead to handle the IO redirection at a lower level. As part of the script launched with lldb you could do something like this:
|
FWIW this is much easier now with os log |
have a link with more info? |
Hmm. Looks like there's some need for blog posts about this. But a simple example of this is:
There are some things with usage about this that you have to handle, like changing the predicate to include more things if you want logs from |
@@ -9,3 +9,4 @@ xcrun instruments -w "$uuid" 2>/dev/null | |||
|
|||
xcrun simctl install booted "$app_path" | |||
xcrun simctl launch booted "$app_id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use the --console
flag?
$ xcrun simctl help launch
Usage: simctl launch [-w | --wait-for-debugger] [--console] [--stdout=<path>] [--stderr=<path>] <device> <app identifier> [<argv 1> <argv 2> ... <argv n>]
--console Block and print the application's stdout and stderr to the current terminal.
Signals received by simctl are passed through to the application.
(Cannot be combined with --stdout or --stderr)
--stdout=<path> Redirect the application's standard output to a file.
--stderr=<path> Redirect the application's standard error to a file.
Note: Log output is often directed to stderr, not stdout.
If you want to set environment variables in the resulting environment, set them in the calling environment with a SIMCTL_CHILD_ prefix.
@@ -9,3 +9,4 @@ xcrun instruments -w "$uuid" 2>/dev/null | |||
|
|||
xcrun simctl install booted "$app_path" | |||
xcrun simctl launch booted "$app_id" | |||
tail -f "$HOME/Library/Logs/CoreSimulator/$uuid/system.log" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above. --console
flag works better for me as it doesn't pollute the output with non-app logs.
Right now, we're just printing the pid for the app process after running.
That's not particularly useful, and I often find myself needing to open Xcode
just to use the app in the simulator.
I think there's more we could do here, but for right now, it probably makes
sense to at least tail the logs for the simulator wherever we ran the run
command. It's at least a more useful default behavior than doing nothing.