It’s been 6 years since Apple launched the first version of Swift programming language. During these years, both the language itself and the ecosystem around it have evolved tremendously. And so did the online resources and options on how to learn Swift.
In this article, we are taking a look at a different approach to learning Swift, which is often neglected, but which can be extremely powerful, especially for developers who already know how to code. More specifically, we are going to describe how you can learn Swift practically, by leveraging the resources available on the already mature Swift ecosystem.
So what’s the best way to learn Swift programming practically in order to make iOS apps?
If you already have some programming experience in other languages / areas (JavaScript, C++, web development, etc.), the best way to learn Swift is to learn by doing. Learning Swift practically is the most efficient way to ramp up on iOS development, for people who are already familiar with the basic coding concepts. Let’s see what strategies you can apply to achieve the best outcome.
1. Start Learning Swift with an App Template
First of all, find an existing fully-functional iOS project that you like. It can be an open-source project on Github, but try to find a project from a reputable author or company. Ideally, you get a premium iOS app template, which contains as many features as possible, to allow you to assimilate a lot of Swift knowledge.
Once you find the Swift source code for an app you are passionate about, go through the following steps:
- Set up your dev environment. Do this by simply following the documentation, which will be extremely comprehensive, especially for the paid templates. At this step, you will learn about Xcode, Cocoapods, iOS simulators, and so on.
- Run the app template in Xcode
If you encounter any issues or have additional questions (which by the way, you must have!), try to find the answers online, by simply googling around. There are lots of free Swift tutorials and recipes that will surface easily by a simple Google search. If you went with a premium app template, then you may also want to use their customer support, to get questions that are specific to the source code you’ve bought.
2. Browse the Code and Understand Xcode & High-level Structure
Now that you actually have a fully fledged iOS app running on your computer, with complete access to the source code, this is really where the fun begins.
First of all, try poking around by browsing some code. Open a few Swift files, read some code, see how much of it makes sense to you. Since you already have some basic coding experience, you’ll notice a ton of stuff makes sense.
A nice trick is to find English strings in the app, and search for them in Xcode, to identify where they are coming from. Get familiar with Xcode – all the navigation panels, the editor, maybe set up some preferences (color theme?), key shortcuts, search, running, debugging, etc.
A great way to get familiar with new code is to set up debugging breakpoints. Once you hit a breakpoint, you can see the entire call stack, so you get to truly see how everything is linked together.
3. Make Small Modifications
Now that you have an idea of how the project structure looks like and how Xcode works on a basic level, you can go ahead and try to make small modifications of the app.
Try breaking the app. Make the code not compile, and read the errors. Remove UI elements from the source code and observe them go away in the app.
Take a look a screen and come up with simple modifications such as: changing background colors, changing the color of a button, changing the text of a label, increasing the font size of a title, changing the app name, changing the image of a view, etc.
You will see that Xcode’s search function is extremely powerful here. While making such small modifications, keep reading as much Swift code as possible, in order to get familiar with the Swift syntax.
Keep making modifications that are incrementally more complex. You should soon get to a level where you start poking around with basic UI components (UILabel, UIButton, etc) as well as a little more advanced stuff such as table views, collection views and even networking. Don’t forget to use breakpoints and really get yourself accustomed with a basic debugging flow – it’s insanely powerful.
For total beginners, who have never coded before, some theoretical preparation for Swift programming might be needed. In these cases, try reading a Swift book or going through beginner’s Swift tutorials, in order to grasp the fundamental concepts of programming in general. At each chapter, try mapping that knowledge to the app template you are learning from.
4. Build More Features
This is truly the most important step in the learning process and it is the milestone that will take you the most time. Building new features is the best way to learn Swift practically. And once you start doing it, you will understand exactly why.
Come up with a list of a few features that you’d like to add to the app template. They can be design tweaks, business logic changes or even adding new menu items and screens.
When working on a feature, first try to find if there’s similar functionality already existing in the app template – a similar list, a similarly designed screen, a similar UI component, etc. Then simply look at how that existing piece of app is being built, and try to replicate it for your feature.
Always be googling. Every time you don’t know how to do something or have questions about anything, just google that. There will be at least 2-3 search results that will explain in detail how to achieve something in Swift.
That’s it. This is how you learn Swift practically. Continue building new features, reading existing source code and so on. Publish your app to the App Store eventually, and then repeat.
You’ll notice everything gets easier after each hour spent struggling – your Swift syntax gets better, your UI component knowledge gets better, your coding speed starts picking up steam, your Google searches start decreasing, etc.
Bottom Line on How To Learn Swift Practically
Using iOS app templates is a great way to learn Swift practically, especially for people who already have some programming experience. By jumping straight into coding, the learning curve gets extremely steep, since you learn the entire development spectrum: development setup, Xcode environment, Swift syntax, Swift APIs, etc.
You assimilate all this knowledge much more effectively by executing practically by yourself, rather than by reading books or by mimicking others.
While for complete beginners, tutorials might still be useful, they should be used only as a companion to creating a real iOS app. Even seasoned iOS developers use iOS starter kits to save time or avoid working on boring tasks (remember FB Login integration?).