Setting up a virtual development environment.tutorial 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. @Tutorial {
  2. @Intro(title: "Setting up a virtual development environment") {
  3. Most developers only have access to one or two of the major operating systems for
  4. development. Setting up virtual machines is an important part of developing and testing
  5. cross-platform apps, especially for smaller less-specialized teams.
  6. This tutorial covers VM creation on macOS using UTM. If you prefer to use something else
  7. (such as Parallels), you can do that too.
  8. }
  9. @Section(title: "Windows guests") {
  10. @ContentAndMedia {
  11. These instructions apply to both Windows 10 and Windows 11; choose which version you
  12. want to install before you get started. We recommend Windows 11 because it's better
  13. supported by UTM, especially on Apple Silicon.
  14. - [Windows 11 x64 ISO](https://www.microsoft.com/en-us/software-download/windows11)
  15. - [Windows 11 arm64 ISO](https://www.microsoft.com/en-us/software-download/windows11arm64)
  16. - [Windows 10 x64 ISO](https://www.microsoft.com/en-au/software-download/windows10iso)
  17. - Windows 10 arm64 doesn't support VM hypervisors.
  18. }
  19. @Steps {
  20. @Step {
  21. Install UTM from [its website](https://mac.getutm.app/).
  22. }
  23. @Step {
  24. Download the installer ISO for your chosen Windows version. **Make sure it matches
  25. the architecture of your host machine** (x64 on Intel-based Macs, arm64 on Apple
  26. silicon).
  27. @Image(source: vm-01-02, alt: "A browser window on the Windows download page.")
  28. }
  29. @Step {
  30. Open UTM and click the plus button.
  31. @Image(source: vm-01-03, alt: "A UTM window with the pointer hovering over the plus button.")
  32. }
  33. @Step {
  34. Click Virtualize.
  35. @Image(source: vm-01-04, alt: "A UTM window with the pointer hovering over the Virtualize button.")
  36. }
  37. @Step {
  38. Click Windows.
  39. @Image(source: vm-01-05, alt: "A UTM window with the pointer hovering over the Windows button.")
  40. }
  41. @Step {
  42. Adjust the RAM and CPU cores allocated to the VM if necessary, then click Continue.
  43. Linking `swift-winui` and `swift-uwp`, dependencies of WinUIBackend, can be
  44. extremely memory-intensive; we recommend allocating as much RAM as you can without
  45. compromising your macOS experience.
  46. @Image(source: vm-01-06, alt: "A UTM window with the pointer hovering over the Continue button.")
  47. }
  48. @Step {
  49. Click Browse and select your downloaded ISO file.
  50. @Image(source: vm-01-07, alt: "A UTM window with the pointer hovering over the Open button in a file picker.")
  51. }
  52. @Step {
  53. Ensure that "Install Windows 10 or higher" and "Install drivers and SPICE tools" are
  54. both checked, then click Continue.
  55. @Image(source: vm-01-08, alt: "A UTM window with the pointer hovering over the Continue button.")
  56. }
  57. @Step {
  58. Configure the amount of storage to allocate, then click Continue.
  59. Unless you plan on using this VM for more than just SwiftCrossUI app development,
  60. you probably won't need more than 64 GB.
  61. @Image(source: vm-01-09, alt: "A UTM window with the pointer hovering over the Continue button.")
  62. }
  63. @Step {
  64. Click Continue. We'll set up a shared folder later.
  65. @Image(source: vm-01-10, alt: "A UTM window with the pointer hovering over the Continue button.")
  66. }
  67. @Step {
  68. Name your VM, then click Save.
  69. @Image(source: vm-01-11, alt: "A UTM window with the pointer hovering over the Save button.")
  70. }
  71. @Step {
  72. Click Run. A new window will open for the VM.
  73. @Image(source: vm-01-12, alt: "A UTM window with the pointer hovering over the Run button.")
  74. }
  75. @Step {
  76. When prompted, press a key to boot to the Windows installer. Proceed through
  77. installation as you would on any other machine. Either the Home or Pro editions
  78. are fine.
  79. > Tip: You can choose "I don't have a product key" when asked for one to skip
  80. > activation.
  81. @Image(source: vm-01-13, alt: "A UTM window running the Windows installer.")
  82. }
  83. @Step {
  84. Proceed through the Windows setup flow like normal.
  85. > Tip: If you want to disable at least _some_ of Windows's incessant tracking,
  86. > select a country in the European Union during setup. You can change it to your
  87. > actual home country once you've reached the desktop.
  88. @Image(source: vm-01-14, alt: "A UTM window with the pointer hovering over the Ireland country option.")
  89. }
  90. @Step {
  91. Once you're at the desktop, the UTM Guest Tools installer window should open
  92. automatically. Install the tools and reboot if prompted.
  93. @Image(source: vm-01-15, alt: "A UTM window on the Windows desktop.")
  94. }
  95. Now we'll set up a shared folder. These steps are optional, but recommended if you
  96. want to edit project files with your preferred editor on your host machine.
  97. @Step {
  98. Shut down the VM.
  99. @Image(source: vm-01-16, alt: "A UTM window with the pointer hovering over the Shut Down button in the start menu.")
  100. }
  101. @Step {
  102. Back in the main UTM window, click the edit button in the toolbar.
  103. @Image(source: vm-01-17, alt: "A UTM window with the pointer hovering over the edit button.")
  104. }
  105. @Step {
  106. Navigate to the Sharing tab and click Browse.
  107. @Image(source: vm-01-18, alt: "A UTM window with the pointer hovering over the Browse button.")
  108. }
  109. @Step {
  110. Select the directory you want to share. This should contain all the projects you'll
  111. be editing/testing on Windows.
  112. @Image(source: vm-01-19, alt: "A UTM window with the pointer hovering over the Open button.")
  113. }
  114. @Step {
  115. Ensure the directory share mode is set to SPICE WebDAV, then click Save.
  116. @Image(source: vm-01-20, alt: "A UTM window with the pointer hovering over the SPICE WebDAV button.")
  117. }
  118. @Step {
  119. Boot the VM and log in. The shared directory should show up as a network drive in
  120. File Explorer, usually `Z:\`.
  121. @Image(source: vm-01-21, alt: "A UTM window with a File Explorer window showing the Z drive.")
  122. }
  123. You're now ready to begin setting up a SwiftCrossUI development environment inside your
  124. Windows VM. Head over to <doc:Windows-development> to continue.
  125. }
  126. }
  127. @Section(title: "Linux guests") {
  128. @ContentAndMedia {
  129. You must choose a Linux distribution before creating a VM. We recommend Ubuntu 24.04
  130. because it has the best Swift support. Fedora is also great, but the latest version that
  131. Swift officially supports is a year and a half old.
  132. - [Ubuntu Desktop 24.04 x64](https://ubuntu.com/download/desktop)
  133. - [Ubuntu Server 24.04 arm64](https://ubuntu.com/download/server/arm); Ubuntu doesn't
  134. provide stable arm64 desktop ISO downloads, but it only takes one extra step to
  135. install the Ubuntu desktop environment.
  136. - [Ubuntu Desktop 24.04 arm64 (daily build)](https://cdimage.ubuntu.com/daily-live/20240421/); **unstable**, your mileage may vary
  137. }
  138. @Steps {
  139. @Step {
  140. Install UTM from [its website](https://mac.getutm.app/).
  141. }
  142. @Step {
  143. Download the installer ISO for your chosen Linux distribution. **Make sure it matches
  144. the architecture of your host machine** (x64 on Intel-based Macs, arm64 on Apple
  145. silicon).
  146. }
  147. @Step {
  148. Open UTM and click the plus button.
  149. @Image(source: vm-01-03, alt: "A UTM window with the pointer hovering over the plus button.")
  150. }
  151. @Step {
  152. Click Virtualize.
  153. @Image(source: vm-01-04, alt: "A UTM window with the pointer hovering over the Virtualize button.")
  154. }
  155. @Step {
  156. Click Linux.
  157. @Image(source: vm-02-05, alt: "A UTM window with the pointer hovering over the Linux button.")
  158. }
  159. @Step {
  160. Adjust the RAM and CPU cores allocated to the VM if necessary, then click Continue.
  161. You can probably get away with the default settings here, but you can increase them
  162. later if you need to.
  163. @Image(source: vm-02-06, alt: "A UTM window with the pointer hovering over the Continue button.")
  164. }
  165. @Step {
  166. Click Browse and select your downloaded ISO file.
  167. @Image(source: vm-02-07, alt: "A UTM window with the pointer hovering over the Open button in a file picker.")
  168. }
  169. @Step {
  170. Click Continue.
  171. @Image(source: vm-02-08, alt: "A UTM window with the pointer hovering over the Continue button.")
  172. }
  173. @Step {
  174. Configure the amount of storage to allocate, then click Continue.
  175. Unless you plan on using this VM for more than just SwiftCrossUI app development,
  176. you probably won't need more than 64 GB.
  177. @Image(source: vm-02-09, alt: "A UTM window with the pointer hovering over the Continue button.")
  178. }
  179. @Step {
  180. Select a shared folder if you want, then click Continue.
  181. @Image(source: vm-02-10, alt: "A UTM window with the pointer hovering over the Continue button.")
  182. }
  183. @Step {
  184. Name your VM, then click Save.
  185. @Image(source: vm-02-11, alt: "A UTM window with the pointer hovering over the Save button.")
  186. }
  187. @Step {
  188. Click Run. A new window will open for the VM.
  189. @Image(source: vm-02-12, alt: "A UTM window with the pointer hovering over the Run button.")
  190. }
  191. @Step {
  192. Install your Linux distro like you would on any other machine.
  193. @Image(source: vm-02-13, alt: "A UTM window running the Ubuntu Server installer.")
  194. }
  195. @Step {
  196. If you used an Ubuntu Server installer, run the commands shown to install a
  197. graphical environment.
  198. @Code(name: "InstallDesktop.shell", file: vm-02-14)
  199. }
  200. @Step {
  201. Run the commands shown to enable clipboard sharing and dynamic display resizing.
  202. If you're on an RPM-based distro such as Fedora, replace the `apt` command with
  203. `yum`.
  204. @Code(name: "EnableIntegrations.shell", file: vm-02-15)
  205. }
  206. If you selected a shared directory while creating the VM, you now need to set it up such
  207. that it will automatically be mounted on boot.
  208. @Step {
  209. Add these two lines to the bottom of `/etc/fstab`, replacing `USER` with your Linux
  210. username, and `HOST_USER_ID` with your **macOS** user ID. To find your user ID, run
  211. `id -u` from macOS; if you're the only user on the machine, your ID will most likely
  212. be 501.
  213. > Tip: You can edit `fstab` using `sudo nano /etc/fstab`.
  214. @Code(name: "/etc/fstab", file: vm-02-16)
  215. }
  216. @Step {
  217. Run these commands to install required dependencies, create your mount destinations,
  218. and reboot so that your changes take effect.
  219. @Code(name: "SetUpMount.shell", file: vm-02-17)
  220. }
  221. @Step {
  222. After rebooting, you should find your directory mounted at `~/utm`.
  223. @Image(source: vm-02-18, alt: "A UTM window showing the \"utm\" directory in Nautilus.")
  224. }
  225. You're now ready to begin setting up a SwiftCrossUI development environment inside your
  226. Linux VM. Head over to <doc:Linux-development> to continue.
  227. }
  228. }
  229. }