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.
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.
3. Create your first Project Swift
This is theWelcome Screen when you open XCode. Then click on “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.
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.
After filling in the required information, click next to select your project storage folder.
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:
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” .
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.