I have just found the answer, you can use the springboard:
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let passcodeInput = springboard.secureTextFields["Passcode field"]
passcodeInput.tap()
passcodeInput.typeText("abc\r")