You're about to write your first line of code, so it's time to install Swift!
But first, let us tell you what Swift is. Swift is a powerful and intuitive programming language created by Apple for building apps. It can be used for creating not only iOS but as well as MacOS, TvOS, and WatchOS apps.
Swift was released in 2014 by Apple. In just a few years, it has already overtaken Objective-C in popularity.
One of the key features of swift over other programming language is that it has high readability. The code you will be executing will be very similar to the language we speak. It also offers Type safety and Type inference which will see in the course ahead.
Before we start installing things, we want to mention that there are some online IDEs for Swift such as Online Swift Playground. If you don't want to install things right in the beginning (or don't have a Mac) and want to get started right away, you can do that using the above IDE.
Since Swift 4 is mainly used by Apple for the Development of their apps, and as we are going to focus on building iOS apps, a Mac is must for development.
To learn Swift, we'll need to download and install Xcode. If you do already have Xcode installed, please confirm that it is the correct version, else you will need to update it.
Xcode 9 requires a Mac running macOS 10.13.2 or later. For this you should have MacBook Pro/air mid 2010 or newer
What is Xcode? Xcode is an IDE, or an integrated development environment. It consists of a code editor, tools to compile and run the code, and other tools which are helpful during programming such as debugging tools, etc.
- You can download it from the apple website (Download Link) or you can search it on the Mac App Store. Note that this requires a 5GB download.
- You'll need to have an Apple ID before installing Xcode. If you don't have one, you'll be asked to create one.
- In the process of installing Xcode, you might be asked to update your Mac OS version.
- The OS update can be found in the Updates tab of the Mac App Store, we recommend to update it to the latest version.
- After the installation of the latest Mac OS, go to the Mac App Store and download Xcode or follow the above link.
- To check your installation, just try launching Xcode.
If you already have Xcode installed, we recommend you to update it to the latest version. In particular, please make sure your Xcode version is 9.0 or above.
You can check the version by launching Xcode. If the below screen doesn't show up after you launch Xcode, then click on Xcode on the top-left (in the menu bar) and click on "About Xcode".
We will use the Playground feature of Xcode to get started. Playground allows you to easily experiment and try some code in an interactive way. We recommend this practice for your future projects as well.
To launch playgrounds, do the following.
- Launch Xcode
- Get started with a playground > iOS > Blank > Save it.
To verify, this is how your playground should look:
There's no need to worry if your Xcode Playground doesn't look exactly like this, but it should look similar.
Maybe you're just starting to code and you want to feel like a pro, don't worry we've got you covered. Since this is an IDE, go on to the navigation bar on the top of your screen and click Xcode > Preferences > Fonts & colors and choose a theme as you like. I highly recommend the Default theme as its distinct and easier to work with but feel free to have your own taste.
We're now ready to start coding in Swift!