Common mistakes in iOS Development

John Arnaoutakis
3 min readMar 19, 2023

In this article I would like to summarise some of the most common issues that I have encountered during iOS development. Some of these can be encountered in software development in general, some are a bit more specific to the iOS ecosystem, although the concept is still valuable to every developer.

1. Forgetting about SOLID

SOLID is an acronym for five design principles that every engineer should have in mind. This can come in handy when building apps. By adhering to this set of principles you are making sure that your code is maintainable, flexible, extendable and testable.

  • (S) Single Responsibility Principle — SRP: This design principle states that a class should have only one reason to change or in other words have one responsibility. Make sure that your objects are not doing too much. Break down your code as much as possible. This makes your code more understandable.
  • (O) Open/Closed Principle — OCP: A class should be open for extension but closed for modification. You should write your classes in a way that allows other developers (or future you) to extend its functionality without changing its existing code.
  • (L) Liskov Substitution Principle — LSP: A subclass should be able to be substituted for its superclass without causing issues. You should model your classes based on behaviour. When thinking about this concept I like remembering the following image.
LISKOV SUBSTITUTION PRINCIPLE If It Looks Like A Duck, Quacks Like A Duck, But Needs Batteries — You Probably Have The Wrong Abstraction
  • (I) Interface Segregation Principle — SIP: Classes should not be forced to implement methods that they don’t need.
  • (D) Dependency Inversion Principle — DIP: Classes should depend on abstractions, not on concrete types/implementations. Use protocols instead of passing the concrete type of an object that your class depends on.

Keep those principles on your mind when designing your new classes. It will help you maintain your code and test it. If you are in a team, it can help other developers understand your code easier as well.

2. Ignoring the Xcode console

I am aware of the excitement that you feel while testing your new awesome feature and that your eyes are locked on the simulator but don’t forget the console. The Xcode console is a powerful tool and your friend! It can warn you about issues that might not be visible to the naked eye. One of the most common messages to look out for in the console is layout constraints issues. Breaking constraints can lead to performance issues. Keep an eye on those and fix them. Make this part of your development cycle.

3. Not testing your code

Write tests to test your code. During this process you may realise issues on the structure of your code, behaviour and catch bugs as well! Writing tests is also about setting the expectations right, you are making sure that the code behaves the way that you want it to and also helps you avoid breaking its functionality in the future.

4. Not using Instruments

Instruments is one of the most important and useful tools for iOS development. It gives you the ability to check your application for quality and performance issues. Using this tool you can check for zombie objects, hangs, scrolling hitches and much more. Keep Instruments on your Dock next to Xcode and use it. Learn more about Instruments here.

5. Using the Main thread for everything

The main thread is meant to be used in order to update the User Interface state of your application, receive touches and react to them. If you want to process data, transform it or execute an expensive block of code do it in a background queue or an operation. Blocking the main thread can cause the app to “hang” or “hitch”. This can be described by your users as laggy. If you want to learn more about this I suggest checking out the following WWDC video: Understand and eliminate hangs from your app

I would love to hear about issues that you might have encountered. Please let me know in the comments and if you enjoyed this article, don’t forget to clap 😁

--

--