XCUIDevice setting orientation crashes first time after simulator boots

Originator:dnkoutso
Number:rdar://45094683 Date Originated:10/08/18
Status:Open Resolved:
Product:iOS Product Version:12
Classification:Bug Reproducible:Always
 
Area:
XCTest

Summary:
Setting orientation on the XCUIDevice within a test bundle fails the first time ever but works subsequent times.

Steps to Reproduce:
```
    XCUIDevice *device = [XCUIDevice sharedDevice];
    device.orientation = UIDeviceOrientationLandscapeLeft;
```
Add this to a brand new project in a test case and execute the test.

Expected Results:
Orientation should change and no crash to occur

Actual Results:
I believe orientation appears to change in the simulator but then a crash and test failure occurs only for the first test.

NOTE: If the simulator is already running an at least a single test run was attempted any subsequent attempts will successfully pass.

Exception message:
```
UI Test Activity: 
Assertion Failure: XCUIDeviceOrientationCrashTests.m:19: Failed to set orientation: Error Domain=XCTDaemonErrorDomain Code=15 "Timed out waiting for confirmation of orientation change." UserInfo={NSLocalizedDescription=Timed out waiting for confirmation of orientation change.}
```

Version/Build:
Xcode 10 (10A254a)


Configuration:
iPhone XR Simulator

See also: https://stackoverflow.com/questions/52426297/swift-timeout-when-unit-testing-orientation-changes-after-upgrading-to-xcode-10

Happens in both Swift and ObjC and also happens in both legacy and new build system.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!