/ iOS

iOS / Swift best practices for 2018

Are you learning iOS development? Looking for Swift best practices? This is the right place to start, let's see them all.

Version control

Are you still making backups and copies of your source files? Stop doing that right now! The thing that you'll need is called version control, and you should definitely learn how to use it. There are many of them, but here is the best one.


Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Git is the de facto standard tool for version control and you can learn the basics in just about 15 minutes. If you learn just one thing this year, I'd highly recommend git.


GitHub is a web-based hosting service for version control using git.

GitHub offers you a free tier only for public git repositories, they also have a paid option for private ones. However it's not just a hosting service, it's a complete platform with tools for issue management, project planning and many more through external integrations. I'd say it's worth the money if you want to have private repositories, but if you go just with the free plan, you'll also learn a lot just by using it on a daily basis. 🐱


Use Xcode if you are going to make an iOS application. There is AppCode as an alternative IDE tool, but it's always lagging behind and the vast majority of the community prefers Xcode. 🔨

Project organiaztion

I already made an article about folder structures, naming targets, workspaces and bundle identifiers. You can read about the conventions for Xcode here.

App Icon hell

I made a smart little tool for creating icon assets for apple platforms. The name is iconer, and it's part of the CoreKit tools. If you don't want to waste your time by creating various sizes of application icons, you should definitely give it a try. 😉

Dependency management

Take my advice: do not integrate external dependencies into your project manually. It'll consume too much time. Why the hell should you waste that on dependency management, instead of coding and bug fixing? 😅


However, I'm really against CocoaPods, because it's centralized, it'll eat up 1,5gigs of space (the master repository under ~/.cocoapods), it creates unnecessary things, but it's a standard package manager for iOS projects.

It's the worst option, but it's the most popular one

Until the complete iOS support arrives into the Swift Package Manager or some kind of miracle happens with the underrated Carthage tool, you should use CocoaPods as your main dependency manager. 😢😢😢

Swift language

Oh, you were thinking about starting the project in Objective-🦖-C ? Come on, please forget that stupid idea right now! Swift evolved a lot through time and with the stable ABI it will eventually overcome Objective-C. 🤐

Swift is the only right choice for the sake of future

Believe me, the struggle that we fought in the past will be only a dead memory. Conversion between Swift versions is going to be the thing of a past. Go Swift!!! 😁


This is the hardest and most overrated topic. Let me show you a quick example, using dependency injection, which means just passing an object its instance variables.

Dependency Injection" is a 25-dollar term for a 5-cent concept.

Do not be afraid of architectures and design patterns. Learn them and make them help you, if you have to fight the architecture, you're doing something wrong that menas you should refactor some of your code. There are lots of well explained articles about MVC, MVP, MVVM, VIPER and many more, just type "iOS design patterns" into your search engine. You can even come up with a random one.

Honestly? This is all bullshit.

If you start writing your first app you just have to sit down and think through what do you want to do and how are you going to achieve that. Of course it helps a lot if you see the patterns, but in the end of the day, you'll realize that all of them are made by humans and none of them is perfect. 🤔

Don't be afraid of architectures and design patterns



Resource strings inside your code? That's not good. You should always use strongly typed autocompleted resource identifiers. This is one thing I really envy Android developers, because they have a nice built-in tool to solve all of this.

Until Apple realizes the true power of asset catalogs and gives us an asset compiler, the community is here with the amazing R.swift tool. I don't want to waste much time on it, because it's good, I mean super good. You shoud fire it up and live with it. It'll make your code better. 😎


In the past we had style guides and code conventions, that noone really enforced. Now we have a tool to automate the task. This is a no-brainer, you should use SwiftLint for sure, because it'll save you even from yourself. 🤓

Continuous integration, delivery

Automation is a good thing. It'll help you to maintain code quality.


You should always write tests, I'm not saying that you should go with TDD, but unit tests are good practice. They'll help you to think through the possible mistakes and they validate your codebase. Also UI tests are good for validating the user interface.


Fastlane tools are going to help you automate your development and release process. I was using it for generating screenshots for various screen sizes, but it can do so much more. You should get familiar with it.


Stop here for a while, because this is important. If you choose only one thing from this section, please sign up for Bitrise. It's the best CI tool that you can get today for iOS development and even more. You can run it on your local machine as well. The Bitrise steplib is awesome, basically if you can script your build step, you can automate it with Bitrise. I already shared my struggle with the Xcode build server, but hey: don't listen to me, try it out for yourself. It'll save you hours. 🎉🎉🎉

+1: Danger

To be honest: I've never tried danger systems, but I'll go for it this year, because I've heard lots of good things about it. It runs during your CI process, and gives the chance to automate common code review tasks. Sounds promising? Check it out.

External sources