├── .gitignore ├── README.md ├── contributing.md ├── editors ├── gedit │ ├── README.md │ ├── documents.png │ ├── empty.png │ └── gedit.png ├── notepadplusplus │ ├── README.md │ ├── documents.png │ ├── empty.png │ ├── notepadplusplus.png │ └── workspace.png ├── vscode-linux │ ├── README.md │ ├── breakpoint.png │ ├── create-package.png │ ├── debugging.png │ ├── explorer.png │ ├── install-extension.png │ ├── launch.png │ ├── lldb.png │ ├── open-file.png │ ├── open-package.png │ ├── run-debug.png │ ├── run-file.png │ ├── run-package.png │ ├── testing.png │ └── vscode.png ├── vscode-windows │ ├── README.md │ ├── breakpoint.png │ ├── create-package.png │ ├── debugging.png │ ├── explorer.png │ ├── install-extension.png │ ├── lldb.png │ ├── open-file.png │ ├── open-package.png │ ├── run-package.png │ ├── store.png │ ├── testing.png │ └── vscode.png └── xcode │ ├── README.md │ ├── breakpoint.png │ ├── debugging.png │ ├── file-new.png │ ├── macos-file.png │ ├── macos-playground.png │ ├── package-new.png │ ├── package-output.png │ ├── package.png │ ├── playground-evaluated.png │ ├── playground-new.png │ ├── testing.png │ └── xcode.png └── platforms ├── fedora └── README.md ├── macOS ├── README.md ├── xcode-additional-components.png └── xcode-app-store.png ├── ubuntu └── README.md ├── windows10 ├── README.md ├── app-installer.png └── developer-mode-10.png └── windows11 ├── README.md └── developer-mode-11.png /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Swift Setup 2 | 3 | This repository describes how you can set up a development environment for the [Swift programming language](https://swift.org). 4 | 5 | Our goal is to support the adoption of Swift as a general purpose cross-platform programming language in education. To that end, we provide student-friendly instructions for various platforms, editors, and IDEs that support Swift. 6 | 7 | If you’re interested in learning Swift, please see our [Programming with Swift: Fundamentals](https://www.pwsacademy.org/courses/pws-fundamentals.html) course, for which this repository is a supporting resource. 8 | 9 | ## Platforms 10 | 11 | We only provide instructions for the latest release of each supported platform. These instructions *may* also apply to older releases: 12 | 13 | - [Fedora 40](platforms/fedora/README.md) 14 | - [macOS Sequoia](platforms/macOS/README.md) 15 | - [Ubuntu 24.04 LTS](platforms/ubuntu/README.md) 16 | - [Windows 10](platforms/windows10/README.md) 17 | - [Windows 11](platforms/windows11/README.md) 18 | 19 | ## Editors and IDEs 20 | 21 | - [Gedit](editors/gedit/README.md) 22 | * Fedora 40 23 | * Ubuntu 24.04 24 | - [Notepad++](editors/notepadplusplus/README.md) 25 | * Windows 10 / 11 26 | - [Visual Studio Code (Linux)](editors/vscode-linux/README.md) 27 | * Fedora 40 28 | * Ubuntu 24.04 29 | - [Visual Studio Code (Windows)](editors/vscode-windows/README.md) 30 | * Windows 10 / 11 31 | - [Xcode](editors/xcode/README.md) 32 | * macOS Sequoia 33 | 34 | ## Contributing 35 | 36 | This repository is a community effort, so we welcome contributions. Please see our [guidelines](contributing.md) for writing instructions. 37 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to Swift Setup 2 | 3 | Our instructions are designed to supplement either an introductory programming course in higher education or an advanced programming course in secondary education. Our target audience consists of students taking these courses, and the instructors teaching them. 4 | 5 | With that in mind, please adhere to the following guidelines when contributing instructions. 6 | 7 | ## General 8 | 9 | * Target your instructions at novice students. Only assume basic skills — such as file management and web browsing — but nothing more. In particular, don’t assume the student has prior programming experience, or experience with using a command line interface. 10 | * When your instructions involve a graphical user interface, include a screenshot of the interface to clarify the instructions. 11 | * When referring to actions in a graphical user interface, favor menu commands over keyboard shortcuts. It’s much easier for a student to explore a menu and discover a command, than it is to memorize a keyboard shortcut. 12 | * When your instructions use a command line interface, make sure the commands are explicit and reproducible. Assume the student will copy-and-paste the commands and that they won’t be able to compensate for missing commands (such as using `cd` to navigate between directories). 13 | * Add a footer that includes the date, your name, and a link to your GitHub profile so we can contact you in case your instructions need updating. 14 | 15 | ## Platforms 16 | 17 | * To be included in this repository, a platform must have a recent, stable, binary release. Don’t rely on daily builds or building from source code. 18 | * Base your instructions on a fresh install of the platform and provide installation instructions for required software that is not included with the platform. 19 | * End your instructions by running `swift --version` to verify that `swift` is installed and available on the `PATH`. 20 | 21 | ## Editors and IDEs 22 | 23 | * Use the existing instructions as templates. 24 | * The **Features** section serves to compare the different editors and IDEs, so include this section and use it as a checklist. 25 | * Focus your instructions on the specifics of installing and using the editor or IDE. Assume the course you’re supplementing already explains how to use Swift and the Swift Package Manager; this is not something you should get into. 26 | * For cross-platform editors and IDEs, you may cover multiple platforms in a single document, but only if the differences between these platforms are minimal. If not, create a separate document for each platform. 27 | -------------------------------------------------------------------------------- /editors/gedit/README.md: -------------------------------------------------------------------------------- 1 | # Gedit 2 | 3 | ![](gedit.png) 4 | 5 | [**Gedit**](https://wiki.gnome.org/Apps/Gedit) is the default text editor on Linux distributions that use the [GNOME](http://www.gnome.org) desktop environment. 6 | 7 | ## Features 8 | 9 | Gedit has very limited support for Swift: 10 | 11 | ✅ Syntax highlighting \ 12 | ❌ Formatting \ 13 | ❌ Completion \ 14 | ❌ Quick help \ 15 | ❌ Diagnostics \ 16 | ❌ Fix-its \ 17 | ❌ Refactoring \ 18 | ❌ Run executables \ 19 | ❌ Debugging \ 20 | ❌ Testing 21 | 22 | Nevertheless, it’s useful because it’s included with the GNOME desktop, so it doesn’t require any additional installation steps. 23 | 24 | ## Usage 25 | 26 | Open the **Text Editor** application or start Gedit from the command line: 27 | 28 | ``` 29 | gedit & 30 | ``` 31 | 32 | > **Note**: The ampersand (`&`) after this command is optional. It launches Gedit in the background so that you can continue using the terminal. 33 | 34 | When Gedit launches, it creates an empty file: 35 | 36 | ![](empty.png) 37 | 38 | Save this file with the **.swift** extension to make it a Swift file. 39 | 40 | > **Note**: You may have to reopen the file or set its language from Plain Text to Swift in the status bar to enable syntax highlighting. 41 | 42 | To open existing files, press the **Open** button in the header bar. On the command line, you specify the files you want to open as arguments for the `gedit` command: 43 | 44 | ``` 45 | gedit main.swift square.swift & 46 | ``` 47 | 48 | ![](documents.png) 49 | 50 | When using Gedit, you’ll have to keep a terminal window open as well. Gedit can only edit files, so you’ll have to compile and run your code from the command line. 51 | 52 | --- 53 | 54 | Last updated: 21 Sept. 2022 \ 55 | Author: [Steven Van Impe](https://github.com/svanimpe) 56 | -------------------------------------------------------------------------------- /editors/gedit/documents.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/gedit/documents.png -------------------------------------------------------------------------------- /editors/gedit/empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/gedit/empty.png -------------------------------------------------------------------------------- /editors/gedit/gedit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/gedit/gedit.png -------------------------------------------------------------------------------- /editors/notepadplusplus/README.md: -------------------------------------------------------------------------------- 1 | # Notepad++ 2 | 3 | ![](notepadplusplus.png) 4 | 5 | [**Notepad++**](https://notepad-plus-plus.org) is popular replacement for the default **Notepad** text editor that comes with Windows. 6 | 7 | ## Features 8 | 9 | Notepad++ has very limited support for Swift: 10 | 11 | ✅ Syntax highlighting \ 12 | ❌ Formatting \ 13 | ❌ Completion \ 14 | ❌ Quick help \ 15 | ❌ Diagnostics \ 16 | ❌ Fix-its \ 17 | ❌ Refactoring \ 18 | ❌ Run executables \ 19 | ❌ Debugging \ 20 | ❌ Testing 21 | 22 | ## Installation 23 | 24 | To install Notepad++, download the latest 64-bit installer from [notepad-plus-plus.org](https://notepad-plus-plus.org/downloads/). 25 | 26 | ## Usage 27 | 28 | When you launch Notepad++, it creates an empty file: 29 | 30 | ![](empty.png) 31 | 32 | Save this file with the **.swift** extension to make it a Swift file. 33 | 34 | To open existing files, select **File ▸ Open...** from the menu bar: 35 | 36 | ![](documents.png) 37 | 38 | To open a Swift package, select **File ▸ Open Folder as Workspace...** from the menu bar: 39 | 40 | ![](workspace.png) 41 | 42 | When using Notepad++, you’ll have to keep a terminal window open as well. Notepad++ can only edit files, so you’ll have to compile and run your code from the command line. 43 | 44 | --- 45 | 46 | Last updated: 5 Nov. 2020 \ 47 | Author: [Steven Van Impe](https://github.com/svanimpe) 48 | -------------------------------------------------------------------------------- /editors/notepadplusplus/documents.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/notepadplusplus/documents.png -------------------------------------------------------------------------------- /editors/notepadplusplus/empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/notepadplusplus/empty.png -------------------------------------------------------------------------------- /editors/notepadplusplus/notepadplusplus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/notepadplusplus/notepadplusplus.png -------------------------------------------------------------------------------- /editors/notepadplusplus/workspace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/notepadplusplus/workspace.png -------------------------------------------------------------------------------- /editors/vscode-linux/README.md: -------------------------------------------------------------------------------- 1 | # Visual Studio Code 2 | 3 | ![](vscode.png) 4 | 5 | [**Visual Studio Code**](https://code.visualstudio.com) is a free and open source editor developed by Microsoft. It’s a cross-platform editor that supports many languages, including Swift. 6 | 7 | ## Features 8 | 9 | Out of the box, Visual Studio Code supports syntax highlighting and code formatting for Swift. However, you can greatly extend its functionality by installing the [**Swift extension**](https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang). The result is a very capable editor: 10 | 11 | ✅ Syntax highlighting \ 12 | ✅ Formatting \ 13 | ✅ Completion \ 14 | ✅ Quick help \ 15 | ✅ Diagnostics \ 16 | ✅ Fix-its \ 17 | ✅ Refactoring \ 18 | ✅ Run executables \ 19 | ✅ Debugging \ 20 | ✅ Testing 21 | 22 | ## Installation 23 | 24 | On Linux, Visual Studio Code is distributed as a [**Snap**](https://snapcraft.io) package. The instructions below describe how you can use Snap to install Visual Studio Code for your distribution. 25 | 26 | ### Ubuntu 27 | 28 | Ubuntu has built-in support for Snap. Run the following command to install Visual Studio Code: 29 | 30 | ``` 31 | sudo snap install --classic code 32 | ``` 33 | 34 | ### Fedora 35 | 36 | On Fedora, first install Snap with the following commands: 37 | 38 | ``` 39 | sudo dnf install snapd 40 | sudo ln -s /var/lib/snapd/snap /snap 41 | ``` 42 | 43 | > **Note**: These commands require administrator privileges, so they’ll ask for your password. 44 | 45 | Now log out or restart your system, then install Visual Studio Code: 46 | 47 | ``` 48 | sudo snap install --classic code 49 | ``` 50 | 51 | ## Getting started 52 | 53 | After installation, you can launch Visual Studio Code by pressing the **Super** (or **Command** or **Windows**) key and searching for it: 54 | 55 | ![](launch.png) 56 | 57 | You can also launch it from the command line, using the **`code`** command: 58 | 59 | ``` 60 | code 61 | ``` 62 | 63 | ## Installing the Swift extension 64 | 65 | To install the Swift extension, select **View ▸ Extensions** from the menu bar, search “swift”, and install the extension published by the Swift Server Work Group: 66 | 67 | ![](install-extension.png) 68 | 69 | The Swift extension includes the [**CodeLLDB extension**](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb), on which it depends to run and debug programs using **LLDB**. 70 | 71 | The first time it's activated, the extension will prompt you to configure a Swift-specific version of LLDB: 72 | 73 | ![](lldb.png) 74 | 75 | Select **Global** when you see this prompt. 76 | 77 | ## Editing files 78 | 79 | To edit files with Visual Studio Code, select **File ▸ Open File...** from the menu bar, or specify the files you want to open as arguments for the `code` command: 80 | 81 | ``` 82 | code hello.swift 83 | ``` 84 | 85 | ![](open-file.png) 86 | 87 | If you specify a file that doesn’t exist, Visual Studio Code will create it for you. Alternatively, you can create files by selecting **File ▸ New File** from the menu bar. 88 | 89 | If the file you’re editing contains top-level executable code, you can run it by opening the **Command Palette** (**View ▸ Command Palette...**) and selecting **Swift: Run Swift Script**: 90 | 91 | ![](run-file.png) 92 | 93 | You’ll see the output of your program appear in the integrated terminal. If the terminal is hidden, select **View ▸ Terminal** from the menu bar to show it. 94 | 95 | ## Editing packages 96 | 97 | To create a new Swift package with an executable program, open the **Explorer** (**View ▸ Explorer**) and select **Create Swift Project**: 98 | 99 | ![](explorer.png) 100 | 101 | Then select **Executable**: 102 | 103 | ![](create-package.png) 104 | 105 | To open an existing package, select **File ▸ Open Folder...** from the menu bar and open the directory that contains the **Package.swift** file. 106 | 107 | On the command line, you specify this directory as an argument for the `code` command: 108 | 109 | ``` 110 | code hello 111 | ``` 112 | 113 | ![](open-package.png) 114 | 115 | To run your code, select **Run ▸ Run Without Debugging** from the menu bar or press **Ctrl+F5**: 116 | 117 | ![](run-package.png) 118 | 119 | You’ll see the output of your program appear in the integrated terminal. If the terminal is hidden, select **View ▸ Terminal** from the menu bar to show it. 120 | 121 | If your package contains multiple executable targets, select **View ▸ Run** from the menu bar to open the **Run and Debug** view. There, you can select a target to run: 122 | 123 | ![](run-debug.png) 124 | 125 | ## Debugging 126 | 127 | To debug a program, first set a breakpoint by clicking next to the line of code where you want the debugger to pause execution: 128 | 129 | ![](breakpoint.png) 130 | 131 | Next, select **Run ▸ Start Debugging** from the menu bar or press **F5** to start the debugger: 132 | 133 | ![](debugging.png) 134 | 135 | Use the integrated terminal, the debug console, and the floating toolbar to interact with the program. 136 | 137 | When you’re done debugging, use the **Stop** button on the floating toolbar or press **Shift+F5** to stop the debugger. 138 | 139 | ## Testing 140 | 141 | To run unit tests, select **View ▸ Testing** from the menu bar to open the **Test Explorer**. There, you can either run all tests, or run specific tests or suites: 142 | 143 | ![](testing.png) 144 | 145 | Test results will appear in the Test Explorer, the Test Results pane, and in the editor. 146 | 147 | --- 148 | 149 | Last updated: 19 Oct. 2024 \ 150 | Author: [Steven Van Impe](https://github.com/svanimpe) 151 | -------------------------------------------------------------------------------- /editors/vscode-linux/breakpoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/breakpoint.png -------------------------------------------------------------------------------- /editors/vscode-linux/create-package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/create-package.png -------------------------------------------------------------------------------- /editors/vscode-linux/debugging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/debugging.png -------------------------------------------------------------------------------- /editors/vscode-linux/explorer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/explorer.png -------------------------------------------------------------------------------- /editors/vscode-linux/install-extension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/install-extension.png -------------------------------------------------------------------------------- /editors/vscode-linux/launch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/launch.png -------------------------------------------------------------------------------- /editors/vscode-linux/lldb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/lldb.png -------------------------------------------------------------------------------- /editors/vscode-linux/open-file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/open-file.png -------------------------------------------------------------------------------- /editors/vscode-linux/open-package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/open-package.png -------------------------------------------------------------------------------- /editors/vscode-linux/run-debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/run-debug.png -------------------------------------------------------------------------------- /editors/vscode-linux/run-file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/run-file.png -------------------------------------------------------------------------------- /editors/vscode-linux/run-package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/run-package.png -------------------------------------------------------------------------------- /editors/vscode-linux/testing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/testing.png -------------------------------------------------------------------------------- /editors/vscode-linux/vscode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-linux/vscode.png -------------------------------------------------------------------------------- /editors/vscode-windows/README.md: -------------------------------------------------------------------------------- 1 | # Visual Studio Code (Windows) 2 | 3 | ![](vscode.png) 4 | 5 | [**Visual Studio Code**](https://code.visualstudio.com) is a free and open source editor developed by Microsoft. It’s a cross-platform editor that supports many languages, including Swift. 6 | 7 | ## Features 8 | 9 | Out of the box, Visual Studio Code supports syntax highlighting and code formatting for Swift. However, you can greatly extend its functionality by installing the [**Swift extension**](https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang). The result is a very capable editor: 10 | 11 | ✅ Syntax highlighting \ 12 | ✅ Formatting \ 13 | ✅ Completion \ 14 | ✅ Quick help \ 15 | ✅ Diagnostics \ 16 | ✅ Fix-its \ 17 | ✅ Refactoring \ 18 | ✅ Run executables \ 19 | ✅ Debugging \ 20 | ✅ Testing 21 | 22 | ## Installation 23 | 24 | Download and install Visual Studio Code from [code.visualstudio.com](https://code.visualstudio.com) or from the Microsoft Store: 25 | 26 | ![](store.png) 27 | 28 | After installation, you can launch Visual Studio Code from the **Start** menu. You can also launch it from the command line, using the **`code`** command: 29 | 30 | ``` 31 | code 32 | ``` 33 | 34 | ## Installing the Swift extension 35 | 36 | To install the Swift extension, select **View ▸ Extensions** from the menu bar, search “swift”, and install the extension published by the Swift Server Work Group: 37 | 38 | ![](install-extension.png) 39 | 40 | The Swift extension includes the [**CodeLLDB extension**](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb), on which it depends to run and debug programs using **LLDB**. 41 | 42 | The first time it's activated, the extension will prompt you to configure a Swift-specific version of LLDB: 43 | 44 | ![](lldb.png) 45 | 46 | Select **Global** when you see this prompt. 47 | 48 | ## Editing files 49 | 50 | To edit files with Visual Studio Code, select **File ▸ Open File...** from the menu bar, or specify the files you want to open as arguments for the `code` command: 51 | 52 | ``` 53 | code hello.swift 54 | ``` 55 | 56 | ![](open-file.png) 57 | 58 | If you specify a file that doesn’t exist, Visual Studio Code will create it for you. Alternatively, you can create files by selecting **File ▸ New File** from the menu bar. 59 | 60 | ## Editing packages 61 | 62 | To create a new Swift package with an executable program, open the **Explorer** (**View ▸ Explorer**) and select **Create Swift Project**: 63 | 64 | ![](explorer.png) 65 | 66 | Then select **Executable**: 67 | 68 | ![](create-package.png) 69 | 70 | To open an existing package, select **File ▸ Open Folder...** from the menu bar and open the directory that contains the **Package.swift** file. 71 | 72 | On the command line, you specify this directory as an argument for the `code` command: 73 | 74 | ``` 75 | code hello 76 | ``` 77 | 78 | ![](open-package.png) 79 | 80 | To run your code, select **Run ▸ Run Without Debugging** from the menu bar or press **Ctrl+F5**. 81 | 82 | Unfortunately, Visual Studio Code will open an external terminal and you won’t see the output of your program. Therefore, you may want to run your program from the integrated terminal instead: 83 | 84 | ![](run-package.png) 85 | 86 | If the terminal is hidden, select **View ▸ Terminal** from the menu bar to show it. 87 | 88 | ## Debugging 89 | 90 | To debug a program, first set a breakpoint by clicking next to the line of code where you want the debugger to pause execution: 91 | 92 | ![](breakpoint.png) 93 | 94 | Next, select **Run ▸ Start Debugging** from the menu bar or press **F5** to start the debugger: 95 | 96 | ![](debugging.png) 97 | 98 | Use the debug console and the floating toolbar to interact with the program. 99 | 100 | When you’re done debugging, use the **Stop** button on the floating toolbar or press **Shift+F5** to stop the debugger. 101 | 102 | ## Testing 103 | 104 | To run unit tests, select **View ▸ Testing** from the menu bar to open the **Test Explorer**. There, you can either run all tests, or run specific tests or suites: 105 | 106 | ![](testing.png) 107 | 108 | Test results will appear in the Test Explorer, the Test Results pane, and in the editor. 109 | 110 | --- 111 | 112 | Last updated: 4 Nov. 2024 \ 113 | Author: [Steven Van Impe](https://github.com/svanimpe) 114 | -------------------------------------------------------------------------------- /editors/vscode-windows/breakpoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-windows/breakpoint.png -------------------------------------------------------------------------------- /editors/vscode-windows/create-package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-windows/create-package.png -------------------------------------------------------------------------------- /editors/vscode-windows/debugging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-windows/debugging.png -------------------------------------------------------------------------------- /editors/vscode-windows/explorer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-windows/explorer.png -------------------------------------------------------------------------------- /editors/vscode-windows/install-extension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-windows/install-extension.png -------------------------------------------------------------------------------- /editors/vscode-windows/lldb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-windows/lldb.png -------------------------------------------------------------------------------- /editors/vscode-windows/open-file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-windows/open-file.png -------------------------------------------------------------------------------- /editors/vscode-windows/open-package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-windows/open-package.png -------------------------------------------------------------------------------- /editors/vscode-windows/run-package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-windows/run-package.png -------------------------------------------------------------------------------- /editors/vscode-windows/store.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-windows/store.png -------------------------------------------------------------------------------- /editors/vscode-windows/testing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-windows/testing.png -------------------------------------------------------------------------------- /editors/vscode-windows/vscode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/vscode-windows/vscode.png -------------------------------------------------------------------------------- /editors/xcode/README.md: -------------------------------------------------------------------------------- 1 | # Xcode 2 | 3 | ![](xcode.png) 4 | 5 | [**Xcode**](https://developer.apple.com/xcode/) is Apple’s integrated development environment (IDE). It includes everything you need to create Swift applications for Apple platforms. 6 | 7 | ## Features 8 | 9 | Xcode is a fully-featured IDE that has all the features you need to get started with Swift on macOS: 10 | 11 | ✅ Syntax highlighting \ 12 | ✅ Formatting \ 13 | ✅ Completion \ 14 | ✅ Quick help \ 15 | ✅ Diagnostics \ 16 | ✅ Fix-its \ 17 | ✅ Refactoring \ 18 | ✅ Run executables \ 19 | ✅ Debugging \ 20 | ✅ Testing 21 | 22 | ## Installation 23 | 24 | You’ve already installed Xcode as part of the installation instructions for Swift on [macOS](../../platforms/macOS/README.md). If not, follow those instructions first. 25 | 26 | ## Usage 27 | 28 | You can use Xcode to create and edit Swift files and packages. Xcode also supports **playgrounds** that evaluate your code line-by-line. 29 | 30 | ### Playgrounds 31 | 32 | To create a playground, select **File ▸ New ▸ Playground...** from the menu bar, then choose the **Blank** template for macOS: 33 | 34 | ![](macos-playground.png) 35 | 36 | This will generate the following playground: 37 | 38 | ![](playground-new.png) 39 | 40 | Replace the contents of this playground with your code, then use the circular button next to your code to evaluate the code up to that point. Xcode will show the results in the sidebar: 41 | 42 | ![](playground-evaluated.png) 43 | 44 | ### Swift files 45 | 46 | To create a Swift file, select **File ▸ New ▸ File from Template...** from the menu bar, then choose the **Swift File** template for macOS: 47 | 48 | ![](macos-file.png) 49 | 50 | This will generate the following file: 51 | 52 | ![](file-new.png) 53 | 54 | To edit an existing file, select **File ▸ Open...** from the menu bar, or — assuming Xcode is the default application for Swift files — double-click the file in Finder. 55 | 56 | You can also use the **`xed`** command in Terminal to edit files with Xcode: 57 | 58 | ``` 59 | xed main.swift 60 | ``` 61 | 62 | ### Swift packages 63 | 64 | To create a new Swift package with an executable program, select **File ▸ New ▸ Package...** from the menu bar, then choose the **Executable** template for macOS: 65 | 66 | ![](package-new.png) 67 | 68 | To edit an existing package, open the **Package.swift** file in Xcode. This will load the entire package: 69 | 70 | ![](package.png) 71 | 72 | To build and run your program, press the **Run** button (the right-facing triangle) or select **Product ▸ Run** from the menu bar. Xcode will open its console window to show the program’s output: 73 | 74 | ![](package-output.png) 75 | 76 | If you don’t see the console, select **View ▸ Debug Area ▸ Activate Console** from the menu bar to show it. 77 | 78 | To debug a program, first set a breakpoint by clicking next to the line of code where you want Xcode to pause execution: 79 | 80 | ![](breakpoint.png) 81 | 82 | Now run the program as before. Xcode will pause execution when it encounters a breakpoint: 83 | 84 | ![](debugging.png) 85 | 86 | When you’re done debugging, press the **Stop** button, which is next to the **Run** button. 87 | 88 | To run your test targets, select **Product ▸ Test** from the menu bar, then select **View ▸ Navigators ▸ Tests** to see the results: 89 | 90 | ![](testing.png) 91 | 92 | --- 93 | 94 | Last updated: 4 Jun. 2025 \ 95 | Author: [Steven Van Impe](https://github.com/svanimpe) 96 | -------------------------------------------------------------------------------- /editors/xcode/breakpoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/xcode/breakpoint.png -------------------------------------------------------------------------------- /editors/xcode/debugging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/xcode/debugging.png -------------------------------------------------------------------------------- /editors/xcode/file-new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/xcode/file-new.png -------------------------------------------------------------------------------- /editors/xcode/macos-file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/xcode/macos-file.png -------------------------------------------------------------------------------- /editors/xcode/macos-playground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/xcode/macos-playground.png -------------------------------------------------------------------------------- /editors/xcode/package-new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/xcode/package-new.png -------------------------------------------------------------------------------- /editors/xcode/package-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/xcode/package-output.png -------------------------------------------------------------------------------- /editors/xcode/package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/xcode/package.png -------------------------------------------------------------------------------- /editors/xcode/playground-evaluated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/xcode/playground-evaluated.png -------------------------------------------------------------------------------- /editors/xcode/playground-new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/xcode/playground-new.png -------------------------------------------------------------------------------- /editors/xcode/testing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/xcode/testing.png -------------------------------------------------------------------------------- /editors/xcode/xcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/editors/xcode/xcode.png -------------------------------------------------------------------------------- /platforms/fedora/README.md: -------------------------------------------------------------------------------- 1 | # Fedora 40 2 | 3 | [**Fedora**](https://www.fedoraproject.org) has excellent support for Swift and even provides a native package for easy installation. 4 | 5 | To install Swift on Fedora, open the **Terminal** application and run the following command: 6 | 7 | ``` 8 | sudo dnf install -y swift-lang 9 | ``` 10 | 11 | > **Note**: This command requires administrator privileges, so it’ll ask for your password. 12 | 13 | You can now execute the `swift` command to verify which version you have installed: 14 | 15 | ``` 16 | swift --version 17 | ``` 18 | 19 | --- 20 | 21 | Last updated: 14 Oct. 2024 \ 22 | Authors: [Ron Olson](https://github.com/tachoknight), [Steven Van Impe](https://github.com/svanimpe) 23 | -------------------------------------------------------------------------------- /platforms/macOS/README.md: -------------------------------------------------------------------------------- 1 | # macOS Sequoia 2 | 3 | On macOS, Swift comes bundled with [**Xcode**](../../editors/xcode/README.md), which is Apple’s integrated development environment (IDE). Xcode includes everything you need to create Swift applications for Apple platforms. 4 | 5 | Download and install Xcode from the **App Store**: 6 | 7 | ![](xcode-app-store.png) 8 | 9 | Once installed, open Xcode, and it’ll ask your permission to install additional components: 10 | 11 | ![](xcode-additional-components.png) 12 | 13 | Install these components, then open the **Terminal** application and enter the following command: 14 | 15 | ``` 16 | xcode-select -p 17 | ``` 18 | 19 | This command should print **/Applications/Xcode.app/Contents/Developer**, which is the directory where Xcode finds its command line tools. If you see a different directory, enter the following command to set the correct value: 20 | 21 | ``` 22 | sudo xcode-select -s /Applications/Xcode.app/Contents/Developer 23 | ``` 24 | 25 | > **Note**: This command requires administrator privileges, so it’ll ask for your password. 26 | 27 | Finally, run the command below to see what version of Swift is on your system: 28 | 29 | ``` 30 | swift --version 31 | ``` 32 | 33 | The current version of Xcode (16.4) includes Swift 6.1. 34 | 35 | --- 36 | 37 | Last updated: 4 Jun. 2025 \ 38 | Author: [Steven Van Impe](https://github.com/svanimpe) 39 | -------------------------------------------------------------------------------- /platforms/macOS/xcode-additional-components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/platforms/macOS/xcode-additional-components.png -------------------------------------------------------------------------------- /platforms/macOS/xcode-app-store.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/platforms/macOS/xcode-app-store.png -------------------------------------------------------------------------------- /platforms/ubuntu/README.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 24.04 LTS 2 | 3 | [**Ubuntu**](https://ubuntu.com) was the first Linux distribution to support Swift. Together with [Visual Studio Code](../../editors/vscode-linux/README.md), it makes an excellent development platform for students using Linux. 4 | 5 | ## Installation 6 | 7 | These instructions rely on the [**Swift Community Apt Repository**](https://swiftlang.xyz). 8 | 9 | Open the **Terminal** application and run the following commands to install this repository: 10 | 11 | ``` 12 | sudo apt install -y curl 13 | curl -s https://archive.swiftlang.xyz/install.sh | sudo bash 14 | ``` 15 | 16 | You can now install the latest release of Swift with the following command: 17 | 18 | ``` 19 | sudo apt install swiftlang 20 | ``` 21 | 22 | Finally, verify that you can run the following command: 23 | 24 | ``` 25 | swift --version 26 | ``` 27 | 28 | --- 29 | 30 | Last updated: 17 Oct. 2024 \ 31 | Author: [Steven Van Impe](https://github.com/svanimpe) 32 | -------------------------------------------------------------------------------- /platforms/windows10/README.md: -------------------------------------------------------------------------------- 1 | # Windows 10 2 | 3 | The following instructions will help you get started with Swift on Windows 10. 4 | 5 | ## Prerequisites 6 | 7 | Before you install Swift, first enable **Developer Mode**. This is required for the Swift Package Manager to work properly. You can find this setting under **Settings ▸ Update & Security ▸ For developers**: 8 | 9 | ![](developer-mode-10.png) 10 | 11 | Next, install or update **App Installer** from the [Microsoft Store](https://apps.microsoft.com/detail/9nblggh4nns1): 12 | 13 | ![](app-installer.png) 14 | 15 | Alternatively, you can download an MSIX installer [here](https://learn.microsoft.com/en-us/windows/msix/app-installer/install-update-app-installer). 16 | 17 | Updating App Installer will make sure you have the Windows Package Manager (**winget**) installed. 18 | 19 | > **Note**: App Installer requires Windows 10 version 1709 (build 16299), so make sure your system is up-to-date. 20 | 21 | ## Installation 22 | 23 | Swift requires some components from [**Visual Studio 2022**](https://visualstudio.microsoft.com), which is Microsoft’s IDE for development on Windows. Although you won’t use Visual Studio to develop Swift applications, you’ll need some of the libraries that come with it. 24 | 25 | Open **Command Prompt** and run the following command to install the required components: 26 | 27 | ``` 28 | winget install --id Microsoft.VisualStudio.2022.Community --exact --force --custom "--add Microsoft.VisualStudio.Component.Windows11SDK.22000 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64" 29 | ``` 30 | 31 | With these components in place, you can now install Swift and its remaining dependencies (Git and Python): 32 | 33 | ``` 34 | winget install --id Swift.Toolchain --exact 35 | ``` 36 | 37 | Finally, restart your terminal and verify that you can run the following command: 38 | 39 | ``` 40 | swift --version 41 | ``` 42 | 43 | ## Known issues 44 | 45 | - The REPL is currently unavailable on Windows ([#13804](https://bugs.swift.org/browse/SR-13804)). 46 | - Running source files with `swift` is currently unavailable on Windows ([#13805](https://bugs.swift.org/browse/SR-13805)). 47 | - Unicode output may not display properly on the command line. 48 | 49 | --- 50 | 51 | Last updated: 20 Oct. 2024 \ 52 | Authors: [Saleem Abdulrasool](https://github.com/compnerd), [Steven Van Impe](https://github.com/svanimpe) 53 | -------------------------------------------------------------------------------- /platforms/windows10/app-installer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/platforms/windows10/app-installer.png -------------------------------------------------------------------------------- /platforms/windows10/developer-mode-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/platforms/windows10/developer-mode-10.png -------------------------------------------------------------------------------- /platforms/windows11/README.md: -------------------------------------------------------------------------------- 1 | # Windows 11 2 | 3 | The following instructions will help you get started with Swift on Windows 11. 4 | 5 | ## Prerequisites 6 | 7 | Before you install Swift, first enable **Developer Mode**. This is required for the Swift Package Manager to work properly. You can find this setting under **Settings ▸ System ▸ For developers**: 8 | 9 | ![](developer-mode-11.png) 10 | 11 | ## Installation 12 | 13 | Swift requires some components from [**Visual Studio 2022**](https://visualstudio.microsoft.com), which is Microsoft’s IDE for development on Windows. Although you won’t use Visual Studio to develop Swift applications, you’ll need some of the libraries that come with it. 14 | 15 | Open **Terminal** and run the following command to install the required components: 16 | 17 | ``` 18 | winget install --id Microsoft.VisualStudio.2022.Community --exact --force --custom "--add Microsoft.VisualStudio.Component.Windows11SDK.22000 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64" 19 | ``` 20 | 21 | With these components in place, you can now install Swift and its remaining dependencies (Git and Python): 22 | 23 | ``` 24 | winget install --id Swift.Toolchain --exact 25 | ``` 26 | 27 | Finally, restart your terminal and verify that you can run the following command: 28 | 29 | ``` 30 | swift --version 31 | ``` 32 | 33 | ## Known issues 34 | 35 | - The REPL is currently unavailable on Windows ([#13804](https://bugs.swift.org/browse/SR-13804)). 36 | - Running source files with `swift` is currently unavailable on Windows ([#13805](https://bugs.swift.org/browse/SR-13805)). 37 | - Unicode output may not display properly on the command line. 38 | 39 | --- 40 | 41 | Last updated: 20 Oct. 2024 \ 42 | Authors: [Saleem Abdulrasool](https://github.com/compnerd), [Steven Van Impe](https://github.com/svanimpe) 43 | -------------------------------------------------------------------------------- /platforms/windows11/developer-mode-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwsacademy/swift-setup/2cdc7deee8241f7b0f39c6822aa74259423b1080/platforms/windows11/developer-mode-11.png --------------------------------------------------------------------------------