Unable to interact with system dialog (passcode) using XCUITest

My application opens a view controller which requires the user to enter their passcode to continue. I am writing UI automation and have used the record option to attempt to discover the element name that I need to interact with. The recorder tells me to use the following:

app.secureTextFields["Passcode field"].tap()

However when I run the test the secureTextField is not found. When I print out the elements in app there is no evidence of the view controller that is currently in the foreground and only the elements of my own application (which is in the background currently) are listed. I have also attempted to use addUIInterruptionMonitor (suggestions found: here). The test fails on app.tap() stating that the application for target application is not in the foreground.


Is anyone aware of how to access elements of a system dialog currently in the foreground using XCTest?