iOS best practices

Here are practices I found useful when developing iOS.
They can be tools or framework that greatly affect your style. Sometimes, it applies to other platform as well


We’re always looking for ways to structure our apps better, I collect some cool stuffs in [ios-architecture](

Name it right

- [Name It Right](
- [Cocoa style for Objective C](
- [swift-style-guide](
- [swift-style-guide](

Naming is hard. But we can start by naming correctly and with correct spelling. The best way is to stick with the platform naming convention

Project structure

- [iOS App Architecture, Part 1: Setting up](

Some prefer to group their projects by object role, like Model, View, View Controller. But I prefer to group by feature or use case, learning from Clean Architecture

- [Clean Architecture]( When you look at a software system, and all you see is MCV in a web configuration, then the architecture of that system is hiding the use cases of that system and exposing the delivery mechanism.

I often group my code like this

- Share: Contains code that can be useful to other project. Not related to any project. Can be extract to a Pod
- Engine: Contains code that is specific to this project. Like UserManager, ViewAnimator, …
- Modules: Separate each screen into module. In each module, there are view, view model and wireframe

There are some architectures like MVC, MVVM, VIPER, VIP, … and you may want to leverage some templates to help creating projects faster, like


And learn how to make them

- [Custom Xcode File Templates](

There are also some scripts to bootstrap your project

- [crafter]( Crafter — Xcode project configuration CLI made easy
- [xcake]( Create your Xcode projects automatically using a stupid simple DSL.
- [liftoff]( CLI for creating and configuring new Xcode projects

Functional Reactive Programming

The Reactive Extension inspired libraries are cool, and they greatly changes the way you develop, especially signal chaining

- [ReactiveCocoa](
- [RxSwift](

Unidirectional data flow

Another trend is React inspired libraries, which encourage Unidirectional data flow

- [react-native](
- [Swift-Flow](
- [Delta](
- [ReduxKit](

Data manipulation

Leverage some functional style for better data manipulation

- [Swiftz]( It defines functional data structures, functions, idioms, and extensions that augment the Swift standard library.
- [Dollar.swift]( A functional tool-belt for Swift Language similar to Lo-Dash or Underscore.js in Javascript

Prefer decoration over extension

This maybe subjective. But in some case decoration wins

Often when we want to add custom color, font or animate a view, or custom `NSDateFormatter`, we often make categories on `UIColor, UIFont, UIView, NSDateFormatter`, …

But most of the case, we can group them inside class, like `ColorBucket, FontBucket, ViewAnimator, DateFormatterBucket`, …

So, instead of

We can have ColorBucket


- [Mixins and Traits in Swift 2.0](

Another way to add functionality to an entity is mixin, which is cool

IoC container

Usage of IoC container can greatly change the app workflow, which praises Dependency Injection

- [Swinject](
- [Dip](

Single Responsibility Principle

Always keep this in mind :]


Understanding of performance issue, especially some common uses like tableview pre rendering, helps

- [Easy UITableView optimizations](
- [25 iOS App Performance Tips & Tricks](
- [iOS Quick Tip: 5 Tips to Increase App Performance](
- [Mastering UIKit performance](

Main thread

It’s good to care about our main thread so see if it is blocked

- [PSPDFUIKitMainThreadGuard.m]( This is a guard that tracks down UIKit access on threads other than main
- [Watchdog]( Class for logging excessive blocking on the main thread

Overlay app icon with build information

- [Overlaying application version on top of your icon](

Show TODO FIXME as warnings

- [XToDo]( Xcode plugin to collect and list the `TODO`,`FIXME`,`???`,`!!!!`

Use this script in Run Script Build Phase


There are some common needed breakpoints, like [Breakpoints_v2.xcbkptlist](

Code snippets

Code snippets auto generate common code

- [XcodeSwiftSnippets](
- [ACCodeSnippetRepositoryPlugin](

Utility class

We can avoid duplicated helper classes in projects by using some cool frameworks

- [Sugar]( Sugar is a sweetener for your Cocoa implementations.

Xcode plugins

Using Xcode plugins can boost your productivity

- [Xcode Plugins](

And learning to write your own can assist you with more tasks

- [How To Create an Xcode Plugin](

Xcode keyboard shortcuts

Navigate faster

- [Xcode Efficiency Tips: Keyboard Shortcuts](


Build yourself some predefined xcconfig

- [Using xcconfig files for your XCode Project](
- [Warnings-xcconfig]( An xcconfig (Xcode configuration) file for easily turning on a boatload of warnings in your project or its targets.
- [XcodeWarnings]( xcconfig to enable lots of Xcode warnings

Strongly typed resource

There’s some scripts that generate strongly typed resource classes

- [SwiftGen]( A collection of Swift tools to generate Swift code (enums for your assets, storyboards, Localizable.strings, …)
- [R.swift]( Get strong typed, autocompleted resources like images, fonts and segues in Swift projects

Continuous learning

Technologies move really fast. We must learn continuously. I have [ios-resources]( to keep track of all the cool stuffs

- [Programming](
- [How to be awesome Swift developer](

Also, I leverage Github as my notes [ios-issues](


- [ios-good-practices by futurice](
- [What are best practices that you use when writing Objective-C and Cocoa?](
- [iOS-Best-Practices by jverkoey](
- [iOS 7 Best Practices; A Weather App Case Stud](
- [iOS Tips by Krzysztof Zabłocki](

Like what you read? Give Khoa Pham a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.