Edit Swift Files Outside Xcode

Does Xcode’s editor frustrate you? Do you have problems with Xcode’s code completion? Do you wish you could use a different text editor to edit the Swift files in your Xcode projects?

Xcode supports opening and editing Swift files in other text editors, such as BBEdit, Sublime Text, TextMate, and Visual Studio Code. Keep reading to learn how to use your favorite text editor to edit the Swift files in your Xcode projects.

Make Your Text Editor the Default Editor for Swift Files

Start by making your preferred text editor the default editor for Swift files on your Mac. Perform the following steps to change the default editor for Swift files:

  1. Go to the Finder.
  2. Select a Swift file.
  3. Press Cmd-I to open the file’s info panel.
  4. Choose your text editor from the Open with menu.
  5. Click the Change All button.


Now when you open a Swift file in the Finder, the file opens in your text editor.

Opening from Xcode

The final step is to open the Swift files in your text editor from Xcode. Select a Swift file in Xcode’s project navigator, right-click, and choose Open with External Editor. The file will open in your text editor.

The changes you make to the text in your text editor will also appear in Xcode. If your project is under version control, an M will appear next to the file in the project navigator, indicating you modified the file.