AppClip Tests: Use of the `_XCAppClipURL` environment variable in UITests

I'm having trouble getting _XCAppClipURL to work in UI tests for my AppClip.

My app clip relies on a query parameter in the URL, but it seems like when running my UI Tests, there is no userActivity with the URL as expected. It works as expected when running the app normally, but does not work in my UI Tests.

I've tried setting the environment variable in my UI Test scheme, as well as in my XCTestCase's setUp function, by setting the value in XCUIApplication.launchEnvironment like this:

    override func setUpWithError() throws {

        continueAfterFailure = false

        app = XCUIApplication()

        app.launchEnvironment["_XCAppClipURL"] = "https://<my url here>"

        app.launch()
    } 

Has anyone had success with this or know if it's a known issue?

I couldn't get this working, my current workaround is to introduce a separate test-only environment variable, that circumvents all of the UserActivity code (that we typically use to intercept the URL).

I suspect that it would also be possible to write the UI test so it opens safari and navigates to the app clip URL, but that requires that all of the other universal link configuration is in place…

AppClip Tests: Use of the &#96;_XCAppClipURL&#96; environment variable in UITests
 
 
Q