ios-simulator

How to rotate ios simulator to landscape from the command line


I am testing a flutter app on an iOS device in a CI/CD system from the commandline, so I am using xcrun simctl commands to controll the simulator.

For tablets, I want to test the app also when the device is in landscape mode. But I cannot find anything on how to rotate an ios simulator from the command line to lanscape.

Can I rotate the ios simulator to landscape using xcrun simctl or some other command line tool?


Solution

  • Expanding on fatfatson's answer, we can also directly invoke the "Orientation" submenu:

    osascript <<END
        tell application "System Events"
            tell application process "Simulator"
                tell menu bar item "Device" of menu bar 1
                    click
                    click menu item "Orientation" of menu 1
                    click menu item "Landscape Left" of menu 1 of menu item "Orientation" of menu 1
                end tell
            end tell
        end tell
    END