Sample apps for Swift on Windows, showcasing how to build Windows Apps using the Windows App SDK through the Swift/WinRT language projection.
- Install latest Swift SDK from https://www.swift.org/download/
- Install latest CMake:
winget install --id Kitware.CMake
- Windows SDK 10.0.20348.0: https://go.microsoft.com/fwlink/?linkid=2164145
- Visual Studio Community with C++ build tools
VSCode is the editor of choice for developing Windows apps on Swift. You can install it from https://code.visualstudio.com/download.
If you choose to use Visual Studio Code, you'll need to install these extensions:
The build of the Windows applications is done through a combination of CMake and SPM. The CMake portion of the build handles tasks that SPM currently doesn't support. The CMake configure
step is responsible for restoring NuGet packages and generating the Swift/WinRT bindings.
Each sample application has it's own top-level directory in this repo. You can open the corresponding .code-workspace
file in VSCode for the sample and build using Terminal->Run Build Task...
or by pressing Ctrl+Shift+B
.
If you'd prefer command line builds, you can first run the configure step of the build (cmake --preset debug
) before running cmake --build --preset debug
.
In order to use the WindowsAppSDK in a Swift application, there are files that need to be copied next to the .exe
file itself, which isn't something SPM supports. The WindowsApplicationSetup.cmake file handles all of this as part of a post-build step. These files, along with the .exe itself, are copied to the build\bin
folder of the repo. You can run the application from there.
Debugging in VSCode is supported through LLDB. You can simply press F5
or navigate to the Run and Debug
(Ctrl+Shift+D
) pane.