This section describes the Swift specific features and procedures that can be used in your projects.
In this section:
BasicsSwift can be incorporated in CLion as the separate plugin. You can use CLion as Swift IDE on Linux and OS X.
Installation and setting upTo enable the Swift support in CLion, do the following:
- Download the plugin.
- In the Settings/Preferences dialog box, select the Plugins option and follow the Install plugin from disk procedure to enable it in CLion.
- Download and set-up the Swift toolchain.
- In the Settings/Preferences dialog box, expand the node and select the Swift option of the left pane.
- On the right pane, specify the Swift SDK home directory (on OS X the default is /Library/Developer/Toolchains/swift-latest.xctoolchain, and on Linux it’s empty): In the text field, type the path to the Swift SDK directory or click the button to choose.
If you want to enable the Swift debugger, select the Use Swift debugger
Note: currently you need to switch-off the debugger when you are working with non-Swift programs.
Using CMake Live templates
Since CLion is based on CMake project model, to simplify the configuration process we
recommend you to use a special CMake
live template that adds a Swift build target:
SWIFT_SDK variable expands to the value specified in the settings.
The resulted CMake configuration file may look as follows:
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.