iOS deep linking with Xcode UI testing

I want to test parts of my app UI in isolation, so avoid having to drill down from the splash screen to the pages in question. My app implements deep linking, but I can't figure out how to configure XCUIApplication in the setUp() to trigger the page transition.

I have a method in the app delegate called openURL() which handles this for the production app. It works great, but when I call it (below), nothing happens. If I put a breakpoint in openURL() it never even gets hit.

    override func setUp() {
        continueAfterFailure = false

        guard let url = NSURL(string: "fooapp://page/3") else {
            fatalError("Couldn't create URL")


What I really want is to set UIApplicationLaunchOptionsURLKey in launchOptions and just let the app behave as if it received an external URL. I see launchArguments and launchEnvironment are available on XCUIApplication, but then I have to write something special to extract those values out and manually call openURL somewhere in the app delegate. What's the right way to do this?

Post not yet marked as solved Up vote post of jamhughes Down vote post of jamhughes



The openURL still does not work correctly. I am using Xcode 15.0.1 with an iOS 17 simulator. Application launches by openURL API but the app doesn't receive this in onOpenURL.

Isn't the purpose of this function to launch the app by link like deep links?

  • If yes, I can say that it still not working on the latest Xcode and iOS. If I can't receive the URL by onOpenURL I can't test deep links, URL schemes, and Universal links. The app also can't receive the link on launchOptions which is provided to the app through didFinishLaunchingWithOptions.

  • If not, I am truly questioning the purpose of this API. It seems to me it works exactly the same as launch().