alfianlosari / windows-samples

Sample Apps for Swift on Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swift on Windows Samples Apps

Sample apps for Swift on Windows, showcasing how to build Windows Apps using the Windows App SDK through the Swift/WinRT language projection.

Setup

Requirements

  1. Install latest Swift SDK from thebrowsercompany/swift-build
  2. Install latest CMake: winget install --id Kitware.CMake
  3. Windows SDK 10.0.20348.0: https://go.microsoft.com/fwlink/?linkid=2164145
  4. Visual Studio Community with C++ build tools

VSCode

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:

Building

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.

Application Setup / Running the Application

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

Debugging in VSCode is supported through LLDB. You can simply press F5 or navigate to the Run and Debug (Ctrl+Shift+D) pane.

About

Sample Apps for Swift on Windows

License:MIT License


Languages

Language:CMake 73.0%Language:Swift 25.8%Language:C 1.2%