Swift - Environment



Swift is a new generation language developed by Apple to create applications and software for the Apple ecosystem. Due to its speed, safety and modern syntax, it quickly emerged as a preferred language among the developers. Originally Siwft was designed to create applications for iOS and macOS.

However, with the increase in its popularity, developers expanded its versatility. Now Swift is available not only for macOS but for Windows and Linux also and provides cross-platform solutions to the developers. Now let us see how we can install Swift on macOS and Windows step by step.

Installing Swift on macOS

To install Swift on macOS we required Xcode. Xcode is Apple’s integrated development environment(IDE) for all Apple’s platforms. It provides various tools to create apps and support the source code for various programming languages like Swift, Objective-C, Java, Python, C++, C, etc.

So follow the following steps to download Xcode in macOS −

Step 1 − Go to the App Store or you can go to the following link to download the latest version of Xcode:www.swift.org/install/.

Xcode

Step 2 − It will automatically install Xcode on your macOS

Build Succeeded

Step 3 − Now open Xcode and go to file >> New >> Playground.

Step 4 − Now select a blank option and then give the name and then click on the Create button.

Create Button

Step 5 − Now you are ready to write and run your first Swift program.

Installing Swift on Windows

To install Swift on Windows, follow the following steps −

Step 1 − Go to the following link to download the latest version of Swift for your Windows www.swift.org/download/.

Swift Download

Step 2 − Click on Windows x86_64 and it starts downloading.

Step 3 − Go to the download folder and open the downloaded .exe file.

swift Variable

Step 4 − Click on the install button and the installation process will start.

Step 5 − After completing the installation go to the environment variable and check for SDKRoot.

Step 6 − Now go to the command prompt and type the following command −

Swift —version
Advertisements