Skip to content
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

Use lldb to launch macOS applications #50

Closed

Conversation

cameroncooke
Copy link

@cameroncooke cameroncooke commented Oct 7, 2024

Fixes #47

@cameroncooke
Copy link
Author

Sorry for the previous PR originally I thought the issue was a code-signing one and went down a rabbit hole. This fix is much simpler and directly fixes my issues.

@cameroncooke
Copy link
Author

cameroncooke commented Oct 7, 2024

Only, problem I'm seeing with this is that we lose the stderr and stdout. I could open the executable directly instead of app bundle and this would open an external terminal session which would show stdout and stderr but this isn't a nice solution as it takes you out of vscode.

This change uses lldb to launch and debug the app, this also has the benifit of launching the app with full entitlements. It also mirros the Xcode Run action which builds, runs and attaches the debugger.
@cameroncooke
Copy link
Author

cameroncooke commented Oct 7, 2024

Ok, one solution that works is to use lldb instead of open or executing the application directly. This mirrors Xcode's "Run" (Cmd+R) action which builds, runs and attaches a debugger. While this is a behaviour change it's actually what iOS/macOS developers would expect Run to do anyway.

I would also suggest the same is done for apps running in the iOS simulator. Having to run and then later attach the debugger is problematic for debugging events that happen at launch time. However this PR doesn't make that change.

@cameroncooke cameroncooke changed the title Uses open instead of executing from the editor Uses lldb to launch macOS applications Oct 7, 2024
@cameroncooke cameroncooke changed the title Uses lldb to launch macOS applications Use lldb to launch macOS applications Oct 7, 2024
@hyzyla
Copy link
Collaborator

hyzyla commented Oct 7, 2024

For some reason, the version with the LLDB debugger doesn't work for me. Maybe I should give it a chance tomorrow.

Also, I’ve found a way to redirect stdout, but I haven't tried how it would work in vscode:

open -W  --stdout $(tty) /Users/hyzyla/Library/Developer/Xcode/DerivedData/ControlRoom-gdvrildvemgjaiameavxoegdskby/Build/Products/Debug/Control\ Room.app/ 

@cameroncooke
Copy link
Author

That's interesting, I personally like the launching with debug session option as this not only fixes the issues I was having it's also representative to how Xcode works when running the app. It always starts a debug session, this was already a pain point for me using this library having to manually attach the debugger.

@hyzyla what error did you see when trying to launch the app using lldb?

@cameroncooke
Copy link
Author

For some reason, the version with the LLDB debugger doesn't work for me. Maybe I should give it a chance tomorrow.

Also, I’ve found a way to redirect stdout, but I haven't tried how it would work in vscode:

open -W  --stdout $(tty) /Users/hyzyla/Library/Developer/Xcode/DerivedData/ControlRoom-gdvrildvemgjaiameavxoegdskby/Build/Products/Debug/Control\ Room.app/ 

This looks like a great quick fix, maybe we could add new build options (run with debugger) and run (without debugging) that way we can choose.

@cameroncooke
Copy link
Author

cameroncooke commented Oct 8, 2024

Technically if you honour the selected scheme sweetpad should attach the debugger if the scheme has that Debug executable option enabled:

Screenshot 2024-10-08 at 09 50 18

Currently, the run command ignores this. I think it should honour this and use lldb as per my PR if this option is enabled in the scheme otherwise use the open command. This should be the same for running apps in the simulator too.

@cameroncooke
Copy link
Author

I am going to close this, for now, will have another PR up shortly that doesn't break existing functionality

@cameroncooke cameroncooke deleted the fix_macos_launch_issue branch October 17, 2024 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

macOS app entitlements issue
2 participants