UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Trying to use deeplink URL to launch app

Forums > SwiftUI

Hi folks, I'd appriciate any pointers here. I'm trying to learn how to use deeplinks to open and control an app. So i've setup the schema in Xcode and indeed my app opens when I specify a URL in Safari or via

xcrun simctl openurl booted myApp://

So far so good.

But I can't seem to interogate the URL in the app. If I run the code below I never see the URL printed in the console, I simply see

About to evaluate URL
Launch Options: nil
Evaluate URL done

So clearly the URL is not being passed through.

Any ideas?

import SwiftUI

struct MyApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

    var body: some Scene {
        WindowGroup {

class AppDelegate: NSObject, UIApplicationDelegate {
    var deepLinkURL: URL?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {

        print("About to evaluate URL")
        print("Launch Options: \(String(describing: launchOptions))")
        if let url = launchOptions?[.url] as? URL {
            deepLinkURL = url
            print("Deep Link URL: \(url)")
        print("Evaluate URL done")

        return true


BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.