Swift dev env for VSCode users

(Pranjal Yadav) #1

I was not sure to create a new topic as a very similar topics exists, but putting this under the vim title might not have brought you here in the first place

If you don’t want to rely on GoogleColab completely and want to setup swift locally and use it inside VSCode, follow the steps at https://bit.ly/2SYWZzB

You need to remember few things

  • Some of the steps (specially 7 and 8) might not work straight away for you and my advice is DON’T PANIC!
  • All you need to do is look at the error and it will mostly correspond to a missing cpp header file
  • Google the header file as is with ‘ubuntu’ as keyword and some packages will show up, look through those packages if they have the header file available, install them
  • The once I had to install were clang, llvm, npm, nodejs, ghc, icu-devtools, libicu-dev, libblocksruntime-dev
  • As always, if you find something still missing after above steps, keep looking and ask for help here, I’ll try my best to assist
  • VSCode extensions that I suggest are ’ SourceKit-LSP for Visual Studio Code’ and ‘Swift Language’

If all goes well then it should look something like below

For Mac users: https://nshipster.com/vscode/
Almost similar steps and same advice

Please remember that these installation steps are to install swift with a language server to write swift code inside VSCode. This has nothing to do with the TF 2.0 alpha and those tutorails will not work locally. You can choose to pip update your tensorflow and see if swift talks nicely with it or not (that’s a TODO for me). VSCode will only help you write good swift code and you still have to compile it outside in the terminal, as I have shown, I couldn’t find a swift interpreter support for VSCode yet.

For those enthusiasts who want to try swift with TF, goto https://colab.research.google.com/github/tensorflow/swift/blob/master/notebooks/blank_swift.ipynb
Here you can write everything from scratch for practice and for inspiration read https://github.com/tensorflow/swift/tree/master/docs/site/tutorials

I hope above information was helpful for you, cheers :slight_smile:


CLion IDE for Swift (Linux & Windows 10)
Swift development environment for vim users
(Jeremy Howard (Admin)) #2

Thanks for the links! :slight_smile: Who wants to make a compiled vscode extension available through the vscode extension manager now?..



I was trying to build Swift for tensorflow for ubuntu 16.04 but found a link to download it for that version of linux.

Please see this link

However I am not sure if that is what is required. I am not sure if I have a toolchain or if I need to do something else.

Right now I can’t do anything as I upgraded my Nvidia drivers ready for CUDA10 etc but forgot that the updated drivers do not support the card that runs my video. So my new video card arrives friday so hopefully I can get back on my system without much trouble.


(Pranjal Yadav) #4

This post is about building swift to work on ubuntu inside VScode, I would call out again that it has nothing to do with tensorflow (for now). To answer your question, the link you are using is not what I suggested, you should be using this link.

The downloaded file from above link is what we refer to as a ‘toolchain’, use this and follow the instructions in the post. If you want to play around with swift and tensorflow, please use the notebook links provided in the post. I haven’t yet figured out a stable way of doing that inside VSCode and I’m waiting for the TF RC to take any concrete steps in that direction.

1 Like


Appreciate that advice but as a consequence of other things I have gone to 18.04, but perhaps I have misguided myself, heyho


(Pavel Vasek) #6

I created an azure devops build for it:


It just clones the repo, changes package.json attributes: name, version, publisher from original values (so I am able to publish it) and publishes it. It’s scheduled to run every day if there are any changes.

You can find the extension here:


Of course, once they publish the “official” version I am going to remove this one.

I hope this will help to the users who don’t want to spend their time on it.

1 Like

("Swift is easy to learn but hard to master") #7

There is a Swift Dev Env extension for VSCode—as seen on the recent S4TF newsletter—posted by @dynamicwebpaige on twttr:

Extension link:

[video-to-gif output image]