Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug/test URL opening in my swift app

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.

like image 224
user3325146 Avatar asked Dec 29 '16 08:12

user3325146


People also ask

How do I debug a swift code in Xcode?

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.

What is debugging in Swift?

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.


1 Answers

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.

like image 176
user3325146 Avatar answered Oct 23 '22 07:10

user3325146