Swift on Windows without Visual Studio?

I dunno, other code contained within my executable that executes before and transfers control to the WinMain I wrote counts as a hidden entry point to me :slight_smile:

Yes, I think so. Thanks for setting me straight.

I was more focused on the fact that using two different implementations of the SDK does not seem as a sensible thing to me, and that there does not seem to be a “clean” way to work with the current SDK (which seems to be implemented in a sensible way) and dispense with the installation of Visual Studio.

Yeah, that is sadly the current world that we have. I don't see a way away from this, but if there is a clever thing that does not end up looking like MinGW, I'd be interested in exploring that. At the very least, we can commiserate on this together.

There are people that are interested in a bare metal environment, and the SDK mechanism is the key to enabling that nicely for them even on Windows. I believe that @frzi upthread was interested in something like that.

3 Likes

Is the video/talk available elsewhere? It's showing up as "unavailable" for me on YouTube.

I'm surprised it could be unavailable, the video is public on the LLVM YouTube channel, the title is "2019 LLVM Developers' Meeting: S. Abdulrasool "Porting by a 1000 Patches: Bringing Swift to Windows"

Thanks Max, that worked and now it's also showing up under the original link. I believe this was the "Vinegar" extension interfering, and I always forget to double check without it active.

1 Like

Just as a cross link, see my comment in another topic about updates from The Browser Company that Saleem Abdulrasool joined recently.

For what it's worth, I have a cross platform windows gui app written completely in swift (with some c/c++ code interopted with). The code base is also used to compile on macOS / Linux and android.

When setting up a windows environment, I thought it was pretty painless and felt like setting up a c++ environment. I just installed visual studio 2022, the swift 5.8 tool chain, and built the project from visual studio code (all inside windows)

I was pleasantly surprised how easy it was to setup.

3 Likes

This is great to hear. Actually, I believe that there are further improvements that are forthcoming that will make the process even better :slight_smile:

This includes things like dropping the ordering requirement (VS must be installed prior to Swift), improvements for dealing with VS upgrades, and there is hope that we can get to the point where we can even remove the requirement for administrator access (with per-user installs instead). Recent changes should also allow building without the VS Developer Command Prompt for SPM based packages.

There are already in flight improvements to SPM and LSP that should make the rest of the process nicer as well.

4 Likes

Well I'm extremely grateful to your efforts to making this a reality. Not only that, but thanks to your public examples, I had more than enough direction to implement dedicated windows CI (outside of GHA) so my entire cross platform swift workload is covered.

I can literally use swift as a c++ replacement. Not only for dedicated applications with the same feature set and coverage that the equivalent application has on darwin systems, but for other fun things like spinning up IMGUI backed libraries for video game mods on windows.

10 Likes

I always thought that porting Swift by using MSVC requiring Visual Studio was bad fit.

The natural fit would have been using the Clang toolchain as it is completely free, free from GNU stuff (what I know about) and also LLVM very much an Apple supported project.

The Microsoft compiler support should be optional instead for those who wants to import those libraries.

The LLVM based Swift toolchain is indeed used, albeit the situation is more complex, see this comment and this comment.

2 Likes