The iOS emulator is an integral part of developing any iOS application that cannot be ignored. It’s worth noting that the new emulator for Xcode 9 brings a number of useful features that can make your development more productive. Compared with previous emulator updates, this time has a very significant change.

So let’s get to the heart of this tutorial, which lists the new features I’ve found in the new iOS emulator (and some tricks that work in the old one, too).

1. Use the Xcode emulator in full screen mode

Xcode’s full screen mode is a lifesaver when you’re using a 13-inch Mac. The Xcode emulator used to be unavailable in full screen mode, but now it’s available. Starting with Xcode 9 Beta 3, this feature will be system default, so you don’t have to do anything to enable it.

Update: Some of you may have this turned off by default, so don’t worry, you can always turn it on via the Apple Internal menu. If you want to explore more secret features in the new emulator, you can enable Apple’s hidden internal options.

So, you need to create an empty folder named “AppleInternal” in the root directory, execute the following command and restart the emulator:

sudo mkdir /AppleInternalCopy the code

The new options should show the item ✌️

Note: I tested this step on an emulator of Xcode 9 Beta 3. If you haven’t already downloaded it, please install the latest Xcode here.

2. Open multiple emulators at once

Remember the frustration of testing your application on different emulators? Previously, you could only open one emulator at a time, although there are a number of “hacks” that teach you how to open multiple iOS emulators in older versions of Xcode. But in Xcode 9, this feature is directly available.

3. Scaling the emulator is as simple as resizing a window

Prior to Xcode 9, the only way to resize the emulator was through “Scale Options.” Now Apple has finally opened the resize emulator window. If you have multiple emulators open at once, this small detail adjustment is very useful and can help you organize your workspace efficiently.

4. Record the video of the simulator

In the official “What’s New” documentation for Xcode 9, Apple states that it is now possible to record emulator screen video, even in older versions it was possible to do this using simctl, and there was nowhere on the interface to enable video recording (except for the built-in screen recording in iOS 11). To get a video file, execute the following code:

xcrun simctl io booted recordVideo --type=mp4 <PATH TO VIDEO FILE>Copy the code

Booted – indicates that SimCTL selects the emulator currently started. If you have multiple emulators started, simCTL will select the one currently operating.

5. Use Finder to share files to the emulator

The emulator now has a Finder extension that allows you to share files directly from the Finder window. You can also do something similar with an image/video file by executing the following simctl command:

xcrun simctl addmedia booted <PATH TO MEDIA FILE>Copy the code

I’m glad it works that way, but dragging and dropping files into the emulator window seems a lot faster to me.

6. Open the URL on the emulator

This also works with Simctl, so you can also open custom URL schemes on older versions of the simulator. Drag and drop to execute the following command at any URL you specify:

xcrun simctl openurl booted <URL>Copy the code

See the documentation for a list of all Apple URL Schemes.

7. Quickly find your app’s folder

To introduce a simctl command, you can use a single command to get the application folder on the file system by knowing the application bundle identifier and executing the following command:

xcrun simctl get_app_container booted <APPS BUNDLE ID>Copy the code

Or you can use the open command to open the target folder faster in Finder:

open `xcrun simctl get_app_container booted <APPS BUNDLE ID>` -a FinderCopy the code

8. Start the application in the emulator using Command Line Args

With Simctl, you can also launch an application from a terminal and pass in some command line parameters (and even set some environment variables). This is useful if you want to insert some debugging behavior into your application. Executing the following command will allow you to accomplish this task:

xcrun simctl launch --console booted <BUNDLE ID> <YOUR ARGUMENTS>Copy the code

You can get these command-line arguments from commandline.arguments (here’s a link to the file).

9. Get the complete application message via the Bundle ID

Sometimes it’s useful to find out where an application’s files or temporary data is located on the file system. If you need more comprehensive information than simctl get_app_container, simctl also has a handy little tool called appInfo that displays the information in the following format:

{
   ApplicationType = User;
   Bundle = <PATH TO APP FILE>;
   BundleContainer = <PATH TO FOLDER WITH APP FILE>;
   CFBundleDisplayName = TestiOSApp;
   CFBundleExecutable = TestiOSApp;
   CFBundleIdentifier = "com.ahmed.app.TestiOSApp";
   CFBundleName = TestiOSApp;
   CFBundleVersion = 1;
   DataContainer = <PATH TO YOUR DATA>;
   GroupContainers =     {
   };
   Path = <PATH TO APP FILE>;
   SBAppTags =     (
   );
}Copy the code

Execute the following command and observe the output:

xcrun simctl appinfo booted <BUNDLE ID>Copy the code

Afterword.

IOS emulator is a very powerful tool that can make your development process much faster if you know all the details and tricks. As a good engineer, it is necessary to be familiar with your development tools. The iOS Simulator is a plug-in that allows engineers to inspect any design inside the Simulator. I have no words for the launch of the new Xcode 9 and Simulator, and can’t wait for the public release! There are many more useful features we can implement to maintain visual hierarchy in iOS applications. Also, if I missed something important in this article, feel free to share your thoughts in the comments, which will add some useful development tips to this article.

YouTube video due to the wall, did not do handling, if necessary can go to the original view.

Translation link: medium.com/flawless-ap…