Swift L2: Prepare development environment for Swift 4 on Xcode 10.2

Swift Language

To run examples and instructions for programming Swift on iOS, tvOS, watchOS and MacOS, we will show you how to prepare a development environment with Xcode 10.2.

This is a quick study material, if you’re just starting out with Swift , how to guide it is “Step by step” so you should read and practice from the top down, this document will help you have a total view. before going into other detailed documents.

1. Keep your Mac up to date

Open System Preferences, then select Software Update to check your macOS computer’s updates.

MacOS Software Update
MacOS Software Update

If you see the message “Your Mac is up to date” means everything is ready for the next step. If not, start updating your Mac again, which can take a long time.

2. Download Xcode 10.2 from App Stores

Open the App Store and enter the “Xcode” keyword into the search box.

Click the Get button to download and install Xcode on your Mac.
Click the Get button to download and install Xcode on your Mac.
Open Xcode after installation is complete.
Open Xcode after installation is complete.

3. Create your first Project Swift

This is theWelcome Screen when you open XCode. Then click on “Create a new Xcode project”.

Create a new Xcode project
Create a new Xcode project

After the “Choose a template for your new project” window appears, click the “macOS” tab a -> select the “Command Line Tool”. Click Next button.

We create a simple Project (Console Application, which has no interface).
We create a simple Project (Console Application, which has no interface).

Next, on the “Choose options for your new project” screen you will have to fill in some project-related information as follows:

  • Product Name: App name you intend to develop. In this case we will set it to SwiftBasics.
  • Team: Your Apple development account. They contain your Certificates, Identifiers & Profiles. You can view your account details at here
  • Organization Name: Your Organization Name.
  • Organization Identifier: Your Organization Identifier.
  • Bundle Identifier: A bundle ID or bundle identifier uniquely identifies an application in Apple’s ecosystem
  • Language: Of course, the language must choose Swift.
Choose options for your new project
Choose options for your new project

After filling in the required information, click next to select your project storage folder.

Select the folder containing the new project.
Select the folder containing the new project.

After selecting the archive folder click create to create a new project, the speed is complete depending on your macOS device specification.

Your project after creation will look like the following:

New Xcode Project on MacOS
New Xcode Project on MacOS

4. Run your first Swift Project

main.swift is a source file created when you create the project, you need to run this source file, it will write to the Console screen the words “Hello, world” .

Run your first Swift Project "Hello World"
Run your first Swift Project “Hello World”

If the result is like the image above, you have successfully installed the Swift development environment on MacOS with Xcode. From now on we will use Xcode to run Swift examples.