Why is Toggle's value not changed in Xcode cloud?

In the code below, the check for the toggle value passed in my xcode. However, it failed in cloud, i.e., that value was still "0" after being tapped.

func testToggle() throws {
        let app = XCUIApplication()
        app.launch()
        
        let fieldName = "MyToggle"
        let field = app.switches[fieldName]
        XCTAssertTrue(field.exists, "Field '\(fieldName)' should exist|debug = \(app.debugDescription)")
        let firstMatch = field.switches.firstMatch
        firstMatch.tap()
        
        #if FAILED_XCODE_CLOUD
        // Verify the toggle/switch is in the desired state
        XCTAssertEqual(firstMatch.value as? String, "1", "Field '\(fieldName)' should be ON|debug = \(app.debugDescription)") // "1" is On, "0" is Off
        #endif
    }

In addition, I'd also like to ask why a traverse to firstMatch is needed?

Why is Toggle's value not changed in Xcode cloud?
 
 
Q