Tutorial

iOS Simulator on Steroids: Tips & Tricks in Xcode 9


iOS Simulator is an integral part of any iOS development process. We just can’t ignore it. New Simulator from Xcode 9 brings a lot of useful tricks, which could make you even more productive. Finally, Apple recalled they have Simulator out there! Comparing to previous modest updates, this one seems like a big deal.

So let’s break this down and list all features I found in new iOS simulator (some tricks you can use in the old Simulators as well).

1. Use Simulator in Full-screen mode with Xcode

When you have 13″ screen the full-screen mode for Xcode is a just life saver. Unfortunately, you couldn’t use Simulator with Xcode in the full-screen mode previously. Well now you can 😎

This feature is enabled by default starting from Xcode 9b3. So you don’t even need to do anything to make it work.

Update: It turned out this feature is disabled by default for some people, but don’t worry, you can always enable it via Apple Internal menu as I described further. If you want to explore more secret features in new Simulator, you should enable Apple hidden Internals menu.
internal-menu

To do so you need to create an empty folder with name “AppleInternal” in the root directory. Just run this command below and restart Simulator:

The new menu item should show up. ☝️

Note: I’ve tested this approach on Simulator from Xcode 9b3. If you don’t have it, please download latest Xcode here.

2. Open Multiple Simulators at Once

Do you remember the frustration of testing your app on different simulators? Previously you were forced to open only one Simulator instance at the time. There were many “hacks” how to open multiple instances of iOS simulator in an older version of Xcode. But finally, with Xcode 9 this feature is available out of the box.

3. Resize Simulator just like a regular window

Before Xcode 9, we had “Scale options” only to adjust simulator’s window size. Now Apple finally made resizing of the Simulator’s window available. It’s useful little detail which can help you organize workspace efficiently if you have multiple simulators opened.

4. Record Video of Simulator

In the official “What’s new” document for Xcode 9, Apple claims that now you can record a video of simulator’s screen. It’s not completely true. You can do it even in the older versions with simctl. I didn’t find any evidence you can enable video recording from the interface though (except for built-in screen recording in iOS 11).

For getting your video file, execute the following command:

booted —  means, that simctl selects currently booted Simulator. In case you have more than one booted Simulator, simctl selects currently active instance.

5. Share files to Simulator right from Finder

Now Simulator has Finder extension which allows you to share files directly from the Finder’s window.

You can do something similar with image/video files using the simctl command below:

It’s nice to have such abilities. However, drag&drop file to the Simulator’s window seems much faster for me.

6. Open URLs on Simulator

This one comes with simctl as well. So you can open custom URL schemes on older Simulators too.

Execute the command below with whatever URL you need:

For the list of all Apple’s URL schemes please check out the documentation..

7. Quickly Find App’s Container Folder

One more command from simctl. You can get app’s container on the file system with a single command. You just need to know app’s bundle identifier and execute the command below:

Or you can make it even faster by opening destination folder in Finder with the open command:

8. Launch Your App in Simulator with Command Line Args

With simctl, you can also launch your app from terminal and pass some command line arguments there (you can even setup some environment variables). It can be helpful if you want to add some hidden debug-only behaviour to your app.

The command below help you with that:

You can get these command line arguments from CommandLine.arguments (here is the link to documentation).

9. Get Full Application Info with Bundle ID

Sometimes it’s useful to find out where your app file or temporary data located on the file system. If you need more comprehensive information than simctl get_app_container can give. simctl also has this nice little tool called appinfo which will show you some information in the following format:

Execute command below and explore the output:

One last thing…

iOS Simulator is a very powerful tool which can speed up your development process a lot. But only if you know all little details and tricks. And obviously, as a good engineer, you have to know your tools.

Here at Flawless, iOS Simulator is extremely important for us. Our product is an iOS Simulator plugin which allows engineers to inspect any design on top of implementation right inside Simulator. So I can’t even tell you how happy I’m with this new Xcode 9 and Simulator release. Can’t wait for the public version! So we can implement more useful features to keep a visual quality of iOS apps in a good shape.

Also, if I missed something important feel free to add your tricks in the comments below. I believe it will be really useful to have more tricks in a single place 😊

This is a guest post by Ahmed Sulaiman, Founder and CEO at Flawless. The original post of this article was published on medium.com. You can reach Ahmed via Twitter.

iOS
How To Fetch and Parse JSON Using iOS SDK
SwiftUI
A Beginner’s Guide to NavigationSplitView in SwiftUI for iOS 16
iOS
Best Practice: How to Fetch Remote Images in Swift Projects
Shares