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:
Edit Package.swift
with code completion and highlighting available:
Add dependencies easily with a code completion for project targets:
Import changes in one click:
Invoke Swift Package Manager actions right from the context menu or via Tools | Swift Package Manager
:
Code
Code faster using the same code generation and refactoring actions that you have in the latest AppCode EAP:
Have SourceKit inspections and fix-its displayed right in your code editor:
Run, Debug, Test
Run Configurations are created automatically for all products in your Package.swift:
To Run or Debug your application or tests, select the corresponding Run Configuration and press ⌃R
or ⌃D
:
Linux support
Develop your SPM projects on Linux having almost the same features as on macOS:
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
Impressed Developer says:
October 5, 2018This 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?
Vyacheslav Karpukhin says:
October 5, 2018Correct, CMake is not used for Swift in CLion anymore.
A says:
October 5, 2018This is fantastic!
Ian Partridge says:
October 5, 2018Congratulations, this looks great!
Do you plan to support running Swift projects on Linux in the macOS version of CLion, via Docker?
Stanislav Dombrovsky says:
October 5, 2018In fact, it’s already supported. We plan to cover it in the next blog post about the server-side features. A quick example:
CLion should deploy the Docker container and start Kitura application inside (mapped to the http://localhost:8080 on the host machine).
About other features:
View | Tool Windows | Database
Preferences | Plugins
→ Install Markdown supportPreferences | Plugins
→ Handlebars/MustachePreferences | 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
Ian Partridge says:
October 8, 2018Fantastic, thanks!
Nicolas Da Mutten says:
October 11, 2018Looks 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:
October 11, 2018There 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?
Nicolas Da Mutten says:
October 11, 2018No, 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
Nicolas Da Mutten says:
October 11, 2018I 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:
October 11, 2018Do 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?
Nicolas Da Mutten says:
October 11, 2018Ah, 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:
October 11, 2018Looks 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.
Nicolas Da Mutten says:
October 11, 2018Right! Workaround worked!
I’m probably gonna push that PR 😉
Stanislav Dombrovsky says:
October 11, 2018I’ve just moved it to the correct repository, so consider this one.
Tabor Kelly says:
October 31, 2018Could 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:
November 1, 2018Hi 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.
Satish Babariya says:
November 26, 2018Are 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:
November 26, 2018We 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.
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:
November 26, 2018But 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:
November 27, 20182018.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.
Tabor Kelly says:
February 4, 2019I downloaded and install CLion 2018.3 and it is *so close* to being usable. Unfortunately, SR-7932 (https://bugs.swift.org/browse/SR-7932) breaks debug of “system modules” on Linux.
Stanislav Dombrovsky says:
February 4, 2019Hopefully, it will be resolved somewhen. Unfortunately, we do not have resources to contribute to the Swift language itself so we cannot fix it.
TheIndifferent says:
February 24, 2019Will SPM support be added to AppCode? Now it seems like CLion has way more functionality than AppCode, when would one choose AppCode instead of CLion?
Stanislav Dombrovsky says:
February 25, 2019We will add it to one of the future releases. Adding another project model to AppCode is a big task, but we are working on it to deliver not only the Server-Side Swift, but also the first-class Kotlin/Native support.
@chnmrc says:
January 26, 2020How I can pass -Xcc -I include search path directive to the clion build process?
Regards
chnmrc
Stanislav Dombrovsky says:
January 27, 2020CLion only invokes swift build when building SPM project, so any compiler options should come from Package.swift. AFAIK it’s not possible to add them to Package.swift now.
David Robertson says:
March 16, 2020We seriously don’t have this in AppCode yet? In fact it’s not even possible to edit files in a swift package in AppCode at all unless you have an xcodeproj for it. Which means I can’t use it at all just now.