Introducing Swift for Visual Studio Code

Well, AppKit should already work this way: SPM only AppKit and UIKit might be possible using the new SPM iOS support for Playgrounds?

3 Likes

isn't that a private Apple to SPM extension tho?

SPM support in iPad Swift Playgrounds means the new Swift for TensorFlow will support GPU-accelerated training entirely on an iPad. S4TF is massive enough that we may need to ship a pre-compiled binary for a good developer experience, but SPM supports binary dependencies.

Yes! I've been following your work on that very closely, super impressive stuff. From one high school student to another, salute :wink: I think this widening of the eco-system will help people realise that Swift can be used for even more than Apple platforms and the server – it's an amazing first language to learn, and thanks to your help more and more people will have the opportunity to join this community.

1 Like

Thanks to Santa🎅

I don't know, I assumed it would also work w/ the Xcode bundled SPM/toolchain, but I didn't try it yet.

I'm talking about manifest (Package.swift) extension. It has properties not supported by the open-source SPM manifest. Xcode can use it though to build and sign the actual app.

That's exactly what I'm thinking! I recently commented on a Medium post and someone said they didn't choose Swift for something because it was Apple-specific. Google Colab can work even on a school-issued Chromebook or an iPhone, and bringing Swift back to it is a major step in being cross-platform.

3 Likes

Nice job, mate! :clap:t2:

Thanks for the awesome addition to the Swift development ecosystem!

It would be great if we could also publish the extension in the Open VSX registry. I've explained out the reasoning and process in this issue: Publish in the Open VSX Registry · Issue #90 · swift-server/vscode-swift · GitHub

For anyone avid to use VSCode but who nonetheless misses Xcode's familiar syntax coloring and font, check out the Xcode 12 theme extension on the VSCode marketplace, and don't forget to go into the VSCode settings and change the font to "SFMono-Medium". If you don't already have the font independently installed on your system you can download it on https://developer.apple.com/fonts/.

You'll feel right at home!

2 Likes

I think there's a way to configure a Jupyter notebook to have custom syntax coloring too. After all, Colab once supported Swift, which has different syntax coloring settings than Python. That means there could be Xcode-like syntax coloring on Google Colab.

Is Xcode still required to be installed even using VSCode? I haven't been able to read anything that would confirm or deny that particular point. My initial attempts tell me it is (still required) but I'm not sure if its a bad configuration on my end, so I wanted to confirm with someone else. Thank you! :christmas_tree:

Without CodeLLDB, you won't be able to debug or run anything. If you want to avoid it, it may be better to only install the SourceKit-LSP extension (https://github.com/apple/sourcekit-lsp/tree/main/Editors/vscode). That will give you all the basic functionality (code completion, jump to definition, ...).

I think only testing requires Xcode to be installed ([SR-15020] swift test fails on macOS without Xcode · Issue #4396 · apple/swift-package-manager · GitHub). Everything else should work with a Swift.org toolchain, provided the executables are on your PATH, or you set the extension's path setting to point at your toolchain.

@0xTim Can you confirm/correct?

Pushed a button and everything worked like magic on my machine—fantastic experience, a huge milestone and a delightful new development for the holidays!

9 Likes

Is possible to run/debug a single script file?

Yes unfortunately we do require Xcode to run tests. The test framework on macOS uses XCTest, which is bundled with Xcode to run the tests. This is the only reason you would need Xcode installed.

Of course you could use a docker image and the remote containers extension to run your development environment on Linux and not worry about Xcode at all. The current release of the swift extension has one slight issue with this at the moment in that it gets the LLDB setup incorrect. But I'm hoping to get a fix for this out soon.

EDIT: v0.1.1 fixes the LLDB setup issue I mention above

2 Likes

Not currently.

Is it possible to create an executable file from a single swift file from the command line? I'm not sure how you would do that.

I think he is talking about a script, i.e. a .swift file with the x bit set and swift in the hash bang. Being able to run and debug such would be nice.

But you can also compile a single Swift source into an executable, like so swiftc hello.swift -o hello.

And then there is swift-sh, support for that would also be great.

3 Likes