Xcode 9 – advanced iOS Simulator


IOS Simulator is an integral part of the development process of the iOS, I usually work in a large part of the time in the use of iOS Simulator, compared to Android, iOS Simulator has fast start-up time, higher operating efficiency characteristics. Therefore, use of iOS Simulator is very helpful for improving the development efficiency of our Xcode. 9, there are a lot of new feature you come up!!


1 、 use Simulator in full screen mode of Xcode

If you are using a 13 inch computer, then Xcode full screen mode you should be accustomed to, even if is equipped with a display, I still used to develop Xcode in fullscreen mode. Unfortunately, you can’t use Simulator in the full screen mode of Xcode. After Xcode 9b3, this problem doesn’t exist:

Xcode 9 - advanced iOS Simulator

This function is not the default for all open, if you have Xcode enabled by default this function should not be discouraged, we can open the Apple Internal menu to enable this function through the Apple Internal menu you can dig out more new features Simulator. So here comes the question, how do you start Apple Internal menu? First, create the AppleInternal folder in the more directory, and then restart Simulator:

Xcode 9 - advanced iOS Simulator
CD MKDIR /AppleInternal / sudo

Restart can be seen after the Simulator internal
option up again, you need to download the Xcode version 9b3 or later.

2. Open multiple emulators simultaneously

Remember we used to fit on different sizes of mobile phones? Usually, we can visually see through Storyboard View in different size devices on the form, however, pure Code code interface to start different times to debug the visual simulator. As a developer, you must have thought that if you could start multiple emulators at once, it would be nice to tell you that this is no longer a problem in Xcode 9.

Xcode 9 - advanced iOS Simulator

3, drag to enlarge or reduce Simulator

Before Xcode 9, we need to use command + 1, 2, 3, 4 to adjust the size of Simulator Xcode 9, then I don’t have too much trouble, we can drag to control the size of the simulator. If you have multiple emulators open, it’s very helpful in some detail, and it can help you organize your workspace effectively.

Xcode 9 - advanced iOS Simulator

4, Simulator screen capture

In the official What’s new Xcode 9 document, Apple claims that video of the simulator screen can now be recorded by Apple. In fact, this is not new, even in the old version, we can also implement this function through simctl. You can record from the interface enables video (except iOS 11 built-in screen recording).

Xcode 9 - advanced iOS Simulator

With the command command, we can get the video we want to record.

Xcrun, simctl, IO, booted, recordVideo, --type=mp4, <, PATH, TO, VIDEO, FILE>

Booted – that is, the simctl’s currently selected emulator. If there are currently multiple emulators, then the selected active Simulator is the norm.

5, Finder and Simulator share files

Now that Simulator has Finder extensions, we can share files directly from the Finder window to Simulator.

Xcode 9 - advanced iOS Simulator

Of course, if you are using an older version of Xcode, we can use the simctl command for similar operations:

Xcrun, simctl, addmedia, booted, < PATH, TO, MEDIA, FILE>

This function is great, after all, I prefer to drag and drop to achieve file sharing between Simulator and Finder.

6, open URLs Simulator through
, and also enable Simulator to open URLs through simctl, so you can also open custom URL on the old emulator.

Xcode 9 - advanced iOS Simulator

Execute the following shell command

Xcrun, simctl, OpenURL, booted, < URL>

Apple official document check out the documentation

7, quickly open the app file system

With simctl, you simply need to execute the following command, and you can get the file system of app, but you have to know bundle identifier:

Xcrun simctl get_app_container booted < APPS BUNDLE ID>

Or you can quickly open the target folder in Finder by using the open command:

Open, `xcrun, simctl, get_app_container, booted, < APPS, BUNDLE, ID> ` -a, Finder

8, open the Command in Simulator with simctl APP
, you can start by Command Simulator in app, or do some control of environmental variables, which is very important in automated testing.

Xcode 9 - advanced iOS Simulator

You just need to use the command to do so:

Xcrun, simctl, launch, --console, booted, <, BUNDLE, ID>, <,, YOUR, ARGUMENTS>

9, obtain the app information of info through Bundle ID

Sometimes, we want to get more information about app, and we can get the following format via simctl appinfo:

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

With the following command, you can get the information in the above format:

Xcrun, simctl, appinfo, booted, <, BUNDLE, ID>


IOS Simulator powerful, is our development of the necessary artifact, when you have mastered the details and the use of skills, you can greatly improve your development efficiency. Of course, as the pursuit of an iOS engineer, you should dig it those little-known function, then remember to tell me!

Reference resources

IOS, Simulator, on, Steroids:, Tips, &amp, Tricks, in, Xcode,

The level is limited, if there are omissions, at
. Welcome to exchange, welcome star CNKCQ
left, there is hand blog