The Apple's Simulator User Guide states in Taking a Screenshot or Recording a Video Using the Command Line paragraph:
You can take a screenshot or record a video of the simulator window using the
xcrun
command-line utility.
To record a video, use the recordVideo
operation in your Terminal:
xcrun simctl io booted recordVideo <filename>.<extension>
Note that the file will be created in the current directory of your Terminal.
If you want to save the video file in your Desktop folder, use the following command:
xcrun simctl io booted recordVideo ~/Desktop/<filename>.<extension>
To stop recording, press Control-C
in Terminal.