Rotate iOS Parallel Device Clones to Landscape Mode via Command Line

16 Views Asked by At

I am looking for a way to be able to rotate iOS simulators to landscape mode for device clones (parallel testing) when the tests are launched via command line either using xcodebuild command or fastlane scan (using a fastlane file).

scan(
   workspace: “workspace.xcworkspace”,
   scheme: “UITESTS”,
   testplan: “Landscape”,
   device: “#{device_udid}“,
   parallel_testing: “YES”,
   number_of_retries: 1,
   result_bundle: true,
   output_remove_retry_attempts: true
)

or

sh "xcodebuild -workspace ../workspace.xcworkspace -scheme UITESTS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Pro Max' -testPlan UITESTS -parallel-testing-enabled YES clean build test | xcbeautify"

When either of these run, it will spawn the device clones based off of the destination or device given and then will automatically start running the test cases.

I am using a script to rotate the device to landscape mode (since automatic rotation isn't working):

osascript -e 'tell application "Simulator" to activate' -e 'tell application "System Events" to click menu item "Landscape Left" of menu 1 of menu item "Orientation" of menu 1 of menu bar item "Device" of menu bar 1 of application process "Simulator"'

If I am not running in parallel, this works great since I can launch the simulator, rotate it, then pass the UUID to fastlane scan or xcodebuild to use. But for parallel it always will launch the cloned devices in Portrait and start running the tests and I have no way to run the script to rotate the simulator prior to it starting the test cases. And I can't pass a UUID for the devices that I want to use as parallel clones either.

0

There are 0 best solutions below