Windows development.tutorial 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. @Tutorial {
  2. @Intro(title: "Setting up a development environment on Windows") {
  3. Detailed set up instructions for Windows-based development environments.
  4. In this article we'll focus on developing SwiftCrossUI apps with Swift Bundler, but much of
  5. the information should still apply if you choose to use a different build system.
  6. }
  7. @Section(title: "Installing Swift") {
  8. @ContentAndMedia {
  9. The [Swift installation instructions page](https://www.swift.org/install/windows/)
  10. lists various installation methods; the easiest is the WinGet-based method.
  11. If you already have Swift installed, you can skip this section.
  12. }
  13. @Steps {
  14. > Note: The Visual Studio version Swift depends on may change in the future.
  15. @Step {
  16. Visit the [Swift installation instructions page](https://www.swift.org/install/windows/)
  17. and follow the instructions for installing Swift via WinGet.
  18. @Image(source: windows-01-01, alt: "A browser window showing Swift's Windows installation instructions.")
  19. }
  20. @Step {
  21. Restart your command prompt to ensure Swift is in your path, then double-check it's
  22. been installed correctly by running `swift --version`.
  23. @Code(name: "SwiftVersion.shell", file: windows-01-02)
  24. }
  25. }
  26. }
  27. @Section(title: "Installing Swift Bundler") {
  28. @ContentAndMedia {
  29. [Swift Bundler](https://swiftbundler.dev) unifies your cross platform development
  30. experience with a consistent CLI interface and configuration format.
  31. }
  32. @Steps {
  33. Currently, the only way to install Swift Bundler on Windows is to build it
  34. yourself.
  35. @Step {
  36. Using the developer command prompt or PowerShell, clone Swift Bundler into a
  37. location you don't mind keeping around.
  38. @Code(name: "SwiftBundler.shell", file: windows-02-01.shell)
  39. }
  40. @Step {
  41. Build Swift Bundler for debugging.
  42. Building Swift Bundler for release is extremely memory-intensive on Windows and
  43. likely to fail on lower memory configurations, and since Swift Bundler is mostly
  44. constrained by IO and external processes, there isn't much gain to be had from
  45. release optimizations. We recommend building for debugging on Windows for everyday
  46. use.
  47. @Code(name: "SwiftBundler.shell", file: windows-02-02.shell)
  48. }
  49. Next, we need to add Swift Bundler to the system `Path` so it can be run from any
  50. directory. The following instructions were adapted from
  51. [a eukhost article](https://www.eukhost.com/kb/how-to-add-to-the-path-on-windows-10-and-windows-11/)
  52. which includes additional images that some may find useful; the images depict Windows
  53. 10 but the guide also works on Windows 11.
  54. @Step {
  55. Open the Start menu and search for "environment variables". Select "Edit the system
  56. environment variables".
  57. @Image(source: windows-02-03, alt: "Searching for \"environment variables\" in the Start menu.")
  58. }
  59. @Step {
  60. Click the "Environment Variables…" button.
  61. @Image(source: windows-02-04, alt: "The pointer hovering over the Environment Variables button.")
  62. }
  63. @Step {
  64. In the System Variables section, select the row corresponding to the `Path` variable
  65. and click "Edit…".
  66. @Image(source: windows-02-05, alt: "The pointer hovering over the Edit button.")
  67. }
  68. @Step {
  69. Click New, and enter `absolute\path\to\swift-bundler\.build\release` (replacing
  70. `absolute\path\to` with the appropriate absolute path).
  71. For example, if you built Swift Bundler on your desktop, you would enter
  72. `C:\Users\Username\Desktop\swift-bundler\.build\release`.
  73. @Image(source: windows-02-06, alt: "The pointer hovering over the New button.")
  74. }
  75. @Step {
  76. Save your changes in all open dialogs by clicking OK three times.
  77. @Image(source: windows-02-07, alt: "The pointer hovering over the OK button.")
  78. }
  79. @Step {
  80. **Restart your command prompt**, then run `swift-bundler --version` as a quick
  81. sanity check.
  82. @Code(name: "SwiftBundler.shell", file: swift-bundler-version.shell)
  83. }
  84. }
  85. }
  86. @Section(title: "Installing dependencies for WinUIBackend") {
  87. @ContentAndMedia {
  88. Before you can use <doc:WinUIBackend> you must install two dependencies; the former is
  89. only required at compile time while the later is only required at runtime. **If you're
  90. developing an app, you need both.**
  91. }
  92. @Steps {
  93. > Warning: You may run into strange Swift issues if you use Command Prompt for Swift
  94. > Development. We recommend always using the Native Tools Command Prompt for VS 2022,
  95. > which you can find in the Start menu.
  96. @Step {
  97. Install Windows SDK 10.0.17763.
  98. Note that older versions of Windows had a typo in the version number; if WinGet
  99. can't find version 17763, try 17736 instead.
  100. @Code(name: "InstallSDK.shell", file: windows-03-01.shell)
  101. }
  102. @Step {
  103. Install the WindowsAppSDK 1.5.240205001-preview1 variant for your architecture: [x64](https://aka.ms/windowsappsdk/1.5/1.5.240205001-preview1/windowsappruntimeinstall-x64.exe)/[arm64](https://aka.ms/windowsappsdk/1.5/1.5.240205001-preview1/windowsappruntimeinstall-arm64.exe)
  104. }
  105. }
  106. }
  107. }