Help with swift on windows

Hello there! I'm looking for information about using swift on windows (without linux core). All, that i found on internet is tinysun's SwiftForWindows. But it seems that it can't use swift packages =/ Also i wasn't able to build application, that use URLSession, so i wasnt able to build something worthwhile with that tool.

All i want is to build swift application on windows that work with network. Also it would be great, if i could use swift packages. Is there any way to do such things for now? Or is swift on windows is not ready for such things? Also, there is not much info about swift+windows on internet, so i even don't know where to start, to learn how to do such things... Could somebody give some info or links, that can help me to figure out where to start?) I'm not much in compiler stuff, and even more NOT IN WINDOWS :D So newbie-friendly information welcome :)

What i already tried:

  • Tried to build swift on windows, but readme on github-swift seems not too friendly for newbies, so have no success there :disappointed_relieved:
  • Tried to use tinysun's SwiftForWindows, but wasn't able to figure out how to work with several files there, and wasn't able to build app with URLSession :confused:
  • Tried to use tinysun's compiler (in cmd) to build library to use along with my code, but hade no success there also, because of deficiency of documentation on how to do such things =/

Have you checked Swift/Win32 Programming!? I'm not sure you would be able to use URLSession on Windows anytime soon, but I can be wrong so probably you should ask @compnerd. He is "Swift on Windows" engine. :wink:

These are the instructions to follow to use Swift on Windows Azure DevOps Services | Sign In It is only in the last couple of months that Swift is in a state where it can be used natively on Windows thanks to @compnerd's awesome work. It might indeed be the case that it is not quite ready for what you want to do - depending on how involved in the process you are prepared to get.

I amended the link to point to the Windows Nighties on Azure (I had incorrectly linked to the Github version of the instructions). Also it occurs to me that the very first step in the instructions to Extract the toolchain artefact would not be obvious for someone not familiar with the Azure dashboard. I will submit a pull request to modify the instructions.

In the meantime here are the steps to extract the tool chain artefact.

  1. assuming you are starting here Azure DevOps Services | Sign In
  2. choose Pipelines > Builds from the left of the dashboard.
  3. click on the most recent successful build (i.e at the top of the page)
  4. At the top right of the page to the right of where it says All logs there is a three dot button under this choose Artefacts > toolchain and this will download the toolchain to your machine.

Thank you! I already saw that forum thread (with windows nighties), but, as you mentioned, I could not understand where to get the artifact :) Hope, your instruction help me, so i can go deeper :)

Have not seen it yet. Seems it's pretty new thread. And unfortunately, it's seems too complicated for me for now to understand what happens on those screenshots :sweat: ( I can understand the code, but can hardly understand commands in VScmd. My experience of cmd+swift is limited to swift package manager for now (Linux/Mac). So i never compiled and linked by myself. And hardly understand all that stuff. I will be glad, if you share some docs/tutorials (if you know any) where i can find info on how to do that kind of magic :smile:

I mean after your Windows toolchain was installed you can try to run a sample project (on screenshots). I have not tried by myself but seems like it using CMake to build a project.

The Windows port is improving by leaps and bounds every day (thank you so much, @compnerd!) but unfortunately it doesn’t have Foundation working at the moment because of compiler issues. Tools like the Swift Package Manager require Foundation to build and work.

I see... Was sure, that Foundation already ported, and package manager not ported because of some other reasons. Ok. I guess, that means, that i can use only dll's on win, right? That's not a problem for me :slight_smile: I can use any tool instead of URLSession as long as there clear documentation on how to use it. And here's another wall. I can't find any documentation that covers the question: how to use dll's with swift?

Foundation is nearly ported, but is currently blocked on a couple of compiler level issues that I am investigating. As to your question of of how to use DLLs with Swift - take a look at any post on the internet related to the modulemap construction for Linux shared objects and C code, the concept is the same as is the implementation.

Thanks to everybody on this thread! Especially to @compnerd

With your toolchain I was able to compile my first HelloWorld with library

1 Like

Awesome! Glad to hear that it made it easier for you to get started. Hopefully more improvements will be coming to the nightlies soon :slight_smile:

1 Like