Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

Mastering the assistant editor in Xcode 11

Xcode 11 was introduced during WWDC 2019 and contained improvements in the way the assistant editor works. If you’re using a second editor a lot it can be quite frustrating at first when you try to use the same workflow in Xcode 11 when files are opened in the left editor while you expected them to open in the right editor.

Just like learning how to use the new Xcode Preview pane without SwiftUI you just need to learn how the new editors work in Xcode 11. Once you get it, you’ll see that you will actually improve and speed up your workflow!

What is the Assistant Editor in Xcode?

The Assistant Editor in Xcode is a second editor that automatically displays files that Xcode determines are most helpful to you based on the work you are performing in the primary editor. It’s been used a lot in the Objective-C days where MyClass.h would be opened while editing MyClass.m. You can open the editor from the Xcode menu Editor -> Assisant.

Nowadays, the Assistant Editor is more seen as just a second editor next to the primary editor.

Editor changes introduced in Xcode 11

In Xcode 11 there seems to be no limit anymore to how many editors you can open:

There's no limit to the amount of open Xcode 11 Editors
There’s no limit to the amount of open Xcode 11 Editors

The new editor is one of the biggest changes introduced in Xcode 11 and introduced in the What’s New in Xcode 11 session during WWDC 2019.

  • Open multiple editors at the same time
  • Focus on a single editor by entering the full-screen editing mode
  • Configure each editor individually as they all have their own minimap, preview, assistant, and other complementary views

Adding an extra editor

A new editor can be added by using File -> New -> Editor or using the shortcut Control + Command + T.

Another easy way to add a new editor is the new button inside the editor header:

The "Add new editor" button
The “Add new editor” button

Using Option while hovering over the button allows you to add a new editor below the current focussed editor.

Opening a file in the assistant editor

As discussed you can’t really open a file in the Assistant Editor but you can open files in a secondary editor.

Before Xcode 11 you would use Option + Open file to open the file in the secondary editor. Doing the same now will open the file in the “next editor”. This means the left editor when the right editor is focused and vice versa.

Restoring the old behavior

First of all, give it a try! Do not directly switch back to the old behavior as the new way can be useful once you get used to it.

If you’re still not able to get used to the new flows you can change the settings to open files like before.

Changing the Xcode 11 Navigation behavior
Changing the Xcode 11 Navigation behavior

Go to Settings -> Navigation and then:

  • Set Navigation to “Uses Primary Editor”
  • Set Optional Navigation to “Uses Second Editor”

Opening a file using the Destination Chooser

Using Option + Shift + Open file allows you to pick the destination editor.

Opening a file using the Xcode 11 Destination Chooser
Opening a file using the Xcode 11 Destination Chooser

This can be handy if you’re working with multiple editors. You can also use the Destination Chooser to open a file in a new editor. This can be done by moving the blue area into a line next to an existing editor.

Open a new editor with the Destination Chooser
Open a new editor with the Destination Chooser

This can be done both horizontally and vertically which allows you to open editors on top of each other:

Two editors on top of each other
Two editors on top of each other

Working with multiple editors by using the focus mode

At first, you might close any secondary editor until your editor is fullscreen again. With Xcode 11 this is no longer needed as you can now focus on a single editor in fullscreen.

You can focus the active editor from the menu in View -> Editor -> Focus or by using the shortcut Control + Shift + Command + Enter. The easiest way is probably by using the new focus button:

Focus an editor in Xcode
Focus an editor in Xcode

Conclusion

Although it might need time to get used to the new editors in Xcode 11, it’s a great new way to improve your development workflow. Make sure you get the most out of the new features!

The refactoring options are also really powerful and these tips will further optimize your workflow.

If you like to improve your workflow, even more, check out the workflow category page. Feel free to contact me or tweet to me on Twitter if you have any additional tips or feedback.

Thanks!

 

Stay Updated with the Latest in Swift & SwiftUI

The 2nd largest newsletter in the Apple development community with 18,327 developers. Don't miss out – Join today:


Featured SwiftLee Jobs

Find your next Swift career step at world-class companies with impressive apps by joining the SwiftLee Talent Collective. I'll match engineers in my collective with exciting app development companies. SwiftLee Jobs