Swift Package Manager support in CLion

Hi everyone,

Today we are excited to announce that the Swift plugin for the latest CLion 2018.3 EAP build supports Swift Package Manager projects directly! Simply open the SPM project and work with it – no additional configuration required.

Read on to learn about all the available features, or watch the short demo below to see them in action:


Project

Have all project dependencies resolved automatically:
Dependencies
Edit Package.swift with code completion and highlighting available:
Completion
Add dependencies easily with a code completion for project targets:
Target completion
Import changes in one click:
Import
Invoke Swift Package Manager actions right from the context menu or via Tools | Swift Package Manager:
Actions

Code

Code faster using the same code generation and refactoring actions that you have in the latest AppCode EAP:
Generate

Have SourceKit inspections and fix-its displayed right in your code editor:
SourceKit

Run, Debug, Test

Run Configurations are created automatically for all products in your Package.swift:
Run Configurations

To Run or Debug your application or tests, select the corresponding Run Configuration and press ⌃R or ⌃D:
Run and Debug

Linux support

Develop your SPM projects on Linux having almost the same features as on macOS:

Linux support

Please note that LLDB in Swift 4.1.x toolchains does not work correctly on Linux, so we recommend using Swift 4.2 toolchains. In addition, we have an issue when it’s not possible to Run or Debug all tests on Linux.

Future plans

During the 2018.3 EAP cycle, we plan to focus on fixing bugs and implementing such features as first-class unit-testing support, on the same level AppCode already offers for macOS. Other features are linked here as subtasks. After finishing most of these tasks, we plan to add support for Swift Package Manager projects in AppCode.

Here’s hoping CLion will become your IDE of choice for cross-platform Swift development!

Your AppCode Team
JetBrains
The Drive to Develop

This entry was posted in Announcement and tagged , , , , . Bookmark the permalink.

21 Responses to Swift Package Manager support in CLion

  1. Impressed Developer says:

    This looks spectacular, and a game changer for Swift on Linux. To confirm, is SPM being used as the project model here? There’s no CMake in the picture at all?

  2. Ian Partridge says:

    Congratulations, this looks great!

    Do you plan to support running Swift projects on Linux in the macOS version of CLion, via Docker?

    • Stanislav Dombrovsky says:

      In fact, it’s already supported. We plan to cover it in the next blog post about the server-side features. A quick example:

      1. Preferences | Plugins – install the “Docker integration” plugin from our plugin repository.
      2. Restart CLion
      3. Setup the docker instance in Preferences | Build, Execution, Deployment | Docker
      4. Checkout the Kitura Sample
      5. Load it in the CLion, wait for all the import / cache steps to be finished
      6. Copy patch contents and apply them via VCS | Apply Patch from Clipboard…
      7. Select the “Docker” Run Configuration and run.

      CLion should deploy the Docker container and start Kitura application inside (mapped to the http://localhost:8080 on the host machine).

      About other features:

      • Requests testing = ⌘N → HTTP Request
      • Database support = View | Tool Windows | Database
      • HTML/JavaScript/CSS support is bundled by default
      • Markdown = Preferences | Plugins → Install Markdown support
      • Handlebars/Mustache = Preferences | Plugins → Handlebars/Mustache
      • FTP/SFTP = Preferences | Build, Execution, Deployment | Deployment (short feature description here)

      Also, this article shows how to use Live Templates, File Templates, File Watchers plugin, and other functionality to setup integration for almost any command-line tool, Stencil files and more. It’s about Sourcery in AppCode, but the same principles can be used for making a custom setup

  3. Looks great!
    However, I can’t get my Vapor project to build. It just is “Building…” forever… Executing “swift package build” works fine though. Are there any limitations?

    • Stanislav Dombrovsky says:

      There are no limitations. Have you used the previous plugin based on the CMake with this project before? If so, please delete .idea folder first and try loading the project again. If it won’t help – could you please share your project with us, so we could check it on our side?

      • No, I developed it with Xcode and cloned it anew. It didn’t work on macOS Mojave and Ubuntu 18.04.

        You can find it here https://git.damutten.ch/Nicolas/HomeControl

        • I forgot to mention: in order for it to compile, you need to implement a struct, that implements the CredentialProvider Protocol and of course all its mentioned protocols too.

          • Stanislav Dombrovsky says:

            Do you mean an actual Build via ⌃R or “Building symbols…” stage after opening the project? For the first time, it can be not fast, since we need to build caches for the project to use for all the code assistance actions. Subsequent loadings should be significantly faster. Run and Debug actions (as well as code highlighting, navigation and other code assistance actions) can’t work until we have all the caches.

            I’ve tried loading your project on macOS and it works after about 1-2 minutes of waiting for caches to be built (after all packages are downloaded). Could you please delete the .idea folder inside the project, try loading it again and wait until all the caching steps are finished – say, during 5 minutes?

          • Ah, it seems that I didn’t wait long enough before first building it.
            I however have another Problem now, but it seems to be a Problem in Vapor: DirectoryConfig.detect() does not work correctly, since it seems to assume some things…

            Th result is, that it does not find my Leaf Templates…

          • Stanislav Dombrovsky says:

            Looks like it’s because of this issue. Workaround:

            1. Select “Edit configurations” in the Run Configurations popup
            2. Set the “Working directory” to the project folder with Package.swift.

          • Right! Workaround worked!

            I’m probably gonna push that PR 😉

          • Stanislav Dombrovsky says:

            I’ve just moved it to the correct repository, so consider this one.

  4. Tabor Kelly says:

    Could you explain how to install Swift support on Linux in clion-183.4139.25? I don’t see any Swift support here.

    • Tatiana Shabaeva says:

      Hi Tabor, Swift plugin needs to be updated and checked internally, after that it’ll be published (likely tomorrow or early next week). Please use previous CLion EAP (build 183.3975.20) in the meantime, sorry for inconvenience.

  5. Are you planning to support Swift Using SourceKit-LSP (https://github.com/apple/sourcekit-lsp)
    If it is then it would be fantastic, Also if Jetbrains decides to create StandAlone Swift IDE then its also be awesome.

    • Stanislav Dombrovsky says:

      Are you planning to support Swift Using SourceKit-LSP (https://github.com/apple/sourcekit-lsp)

      We already have almost everything listed as “not implemented” in SourceKit-LSP implemented in our plugin. And everything that is implemented also works in this plugin. Not clear, why should we add it, if we already provide the same features and even more.

      If it is then it would be fantastic, Also if Jetbrains decides to create StandAlone Swift IDE then its also be awesome.

      CLion = standalone Swift IDE for Swift Package Manager projects for macOS and Linux. So, it’s already here for a long time.

      • Tabor Kelly says:

        But 2018.3, the first stable version to support SPM, still isn’t released. Right?

        So everything you wrote might be true soon, but is surely hasn’t been “already here for a long time.”

        • Stanislav Dombrovsky says:

          2018.3 is the first version supporting SPM directly, without the CMake wrapper. But with the CMake most of these features worked before – yes, with some problems in the resolve/navigation/highlighting, but it also worked. And it had more features implemented if we compare to the current LSP state.

Leave a Reply

Your email address will not be published. Required fields are marked *