Swift/Win32 aims to provide a MVC model for writing applications on Windows. It provides Swift friendly wrapping of the Win32 APIs much like MFC did for C++.
- Latest Swift Development Snapshot (2021-01-26 or later)1
- Windows SDK 10.0.107763 or newer
- CMake 3.16 or newer
1 Stable releases are not currently supported as they are built from release branches, and this project requires the latest development snapshot from the main
branch.
This project requires the latest Swift snapshot (January 26, 2021 or newer). You can use the the snapshot binaries from swift.org or download the nightly build from Azure.
The following example session shows how to build with CMake 3.16 or newer.
cmake -B build -D BUILD_SHARED_LIBS=YES -D CMAKE_BUILD_TYPE=Release -D CMAKE_Swift_FLAGS="-sdk %SDKROOT%" -G Ninja -S .
ninja -C build SwiftWin32 UICatalog
%CD%\build\bin\UICatalog.exe
Building this project with swift-package-manager is supported although CMake is recommended for ease. The Swift Package Manager based build is required for code completion via SourceKit-LSP. It also allows for the use of Swift/Win32 in other applications using SPM. In order to use SPM to build this project additional post-build steps are required to use the demo applications.
The following known limitations are known:
- It is not possible to deploy auxiliary files which are required for Swift/Win32 based applications to function to the correct location.
- It is not possible to build and run multiple demo projects as the auxiliary files collide.
swift build --product UICatalog
copy Examples\UICatalog\UICatalog.exe.manifest .build\x86_64-unknown-windows-msvc\debug\
copy Examples\UICatalog\Info.plist .build\x86_64-unknown-windows-msvc\debug\
swift run UICatalog