In order to record the screen of the iOS simulator, first select a simulator in XCode and run the app, then open a terminal window and run the command:

1
xcrun simctl io booted recordVideo filename.mov

Note: Replace filename in the above command with the real file name

Then you can operate the app in the emulator. When you want to end the screen recording, just press the Ctrl+C key combination in the terminal window. Then you can see the video file in the directory opened in the terminal window。