I recently ran into a situation where I needed to be able to check the current on/off state (NOT whether it is enabled for user interaction) of a UISwitch from within an existing bucket of XCUITests, not an XCTest, and toggle it to a pre-determined state. I had added app state restoration to an old existing app and this is now interfering with a number of existing testcases between runs that expected the UISwitches in particular default states.
Unlike XCTest, within XCUITest you do not have access to the UISwitch state directly.
How is this state determined in Objective-C for an XCUITest?