I am trying to write an app in swift that can be opened with a custom URL scheme. I want to test this functionality by letting my app be launched by opening a URL. How do I debug this in Xcode? Is there a way to simulate URL launching in Xcode?
Edit: It's a macOS app.
Here's my workaround: build the app, copy it into the applications folder so that it registers the URL scheme, open test URL from safari.
When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.
The Swift REPL can be used for debugging, to test and interact with your app. When code breaks, typing repl into LLDB will allow you to interactively test code. You can call methods with different arguments, and test new functions by adding them to your existing code.
OK so after some time experimenting with debug schemes, I have an answer now. After registering the URL scheme in you info.plist, compile and make sure the app is able to be opened by a URL.
Then go to "edit scheme" > info > "wait for executable to be launched" and then run it from Xcode. Now if you click a URL, your app will run with Xcode's debugger attached and your breakpoints will hit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With