CLion 2018.3 Help


Swift can be incorporated in CLion as the separate plugin. You can use CLion as Swift IDE on Linux and macOS.

To enable the Swift support:

  1. Download the plugin.

  2. In the Settings/Preferences dialog (Ctrl+Alt+S) box, select the Plugins option and follow the Install plugin from disk procedure to enable it in CLion.

  3. Download and set-up the Swift toolchain.

  4. In the Settings/Preferences dialog (Ctrl+Alt+S) box, expand the Build, Execution, Deployment node and select the Swift option of the left pane.

  5. On the right pane, specify the Swift SDK home directory (on macOS the default is /Library/Developer/Toolchains/swift-latest.xctoolchain, and on Linux it’s empty):

    cl swiftSDKHome
    In the text field, type the path to the Swift SDK directory or click the browseButton button to choose.

  6. If you want to enable the Swift debugger, select the Use Swift debugger checkbox.
    Note: currently you need to switch-off the debugger when you are working with non-Swift programs.

To create a new Swift project using a project template

  1. On the main menu, choose the File | New Project option.

  2. In the dialog that opens, under Other node of the left pane select Swift Executable.

  3. Go to the right pain. In the text field specify the path to the project and the project's name. Do nothing to use the default settings.

  4. Click create to proceed.

    cl NewSwiftProject

  5. Upon the system prompt, tell CLion where to open your project: in the current or new window.

  6. The resulted CMake configuration file may look as follows:

    cl MySwiftProject

Using CMake Live templates

You can create a project using a special CMake live template that adds a Swift build target:

cl swiftCMake
The SWIFT_SDK variable expands to the value specified in the settings.

Supported features

With Swift plugin enabled, CLion supports the set of the following features:

  • Parse/resolve classes in project and standard library. Note that non-standard libraries are not resolved yet in Swift plugin for CLion

  • Code highlighting and completion

  • Swift code formatter with a separate set of Swift code style settings

  • Navigation actions and File structure view

  • Find usages

  • Rename refactoring

  • Override/Implement for functions and protocols

  • Debugger

Last modified: 14 February 2019