Start by building and running your demo app or an app template you’ve made on the default simulator. Once it launches, move the Simulator icon from the dock and back so that it’s available even if you close Xcode.
Now that your app is running, click the house icon. This is the same as swiping up or clicking the home button on a real device. You’ll see the standard Apple apps installed as well as your app. This is so you can test app interaction. For example, if your app will read from the Photos library, it’ll need the Photos app.
You can add data to many of the apps on the simulator by dragging files from Finder. Here, open the Photos app. Drag and drop an image from your desktop to have it appear here in the library.
You can drag and drop a URL into Safari. Also, if you sign into iCloud, you can transfer data back and forth that way. There’s also a shared clipboard. You can get the simulator clipboard or send your Mac clipboard contents.
The camera button at the top next to the house will take a screenshot and save it to your Mac’s desktop. Hold down Option on your keyboard, and you’ll start a screen recording. There are also commands to do this in the File menu of the Simulator app. The last button on the top rotates the device. Holding Option while clicking the button rotates the device the other way. You can also rotate the device by holding down Command and using the left or right arrow keys. Holding down Command and using the up and down arrow keys changes the volume.
Demonstrations are a good use of the simulator. Sharing the simulator window on a video call is easier than sharing a real device. You can also make the taps appear. You can enable single touches and pinch gestures in the Simulator menu under Settings.
Now, see how a grey circle appears when you tap the screen. Hold down the Option key on the keyboard, and you’ll get two touches so you can rotate and pinch. These circles won’t appear if you record the simulator screen using the simulator’s recording. However, they appear when you share on a video call or use Command-Shift-5 to make a recording or use another screen capture utility.
For an iPad simulator, there are two extra buttons in the toolbar at the top to capture the keyboard and mouse. When you capture the mouse, you get a little grey dot around the pointer. This dot will show up on all screen recordings.
When exercising your app, you use the Device, I/O, and Features menus the most. You can test Face ID, simulate shaking the device, and other common settings. You can even set a latitude and longitude location. There are also settings in the Settings app for all accessibility settings.
The Debug menu mainly modifies graphics performance to help you debug such issues. For instance, you can slow down all animations with this setting. Now, all animations are quite slow, and you can watch them more carefully.
Remember from the lesson that all these files are stored on the file system. A terminal utility called simctl helps work with the simulator. For instance, to get the filepath of the container directory of the demo BragBook app from the running simulator, type this:
xcrun simctl get_app_container booted com.example.bragbookapp
The simctl can do other things like add media to the simulator or install an app executable .ipa. You can also ask it to open a URL. Apps on the phone communicate with each other using URLs, so you can test inter-app communication by passing URLs.
You can even use simctl to send push notifications to your device to test how your app responds to them.
Get the full list of simctl commands by using this command:
xcrun simctl --help
Using simctl is especially helpful if you need to use scripts with your simulator.
You can also run multiple simulators from the File menu of the Simulator app. Alternatively, you can run your app in one of the already running simulators in Xcode by choosing it from this drop-down and clicking the build and run button. Or you can launch it on even another simulator. Though Xcode will only attach to one, you can launch your app on the other simulator by clicking its icon, just like launching a real app on a real device.