Loading... Search articles

Search for articles

Sorry, but we couldn't find any matches...

But perhaps we can interest you in one of our more popular articles?
Open-source iOS apps for learning better practices

Open-source iOS apps for learning better practices

Mar 1, 2022

Written by Rudrank Riyam.

In your iOS development learning journey, you want to understand and use the best practices while writing code. There are many open source apps on GitHub for you to take a look at. These open source projects demonstrate working with Clean Architecture, writing good tests for your native iOS app, and knowing how and what to test. This post discusses some open-source iOS apps that you can take inspiration from to learn better development practices, such as:

  • Clean Architecture
  • Dependency injection
  • Modularizing the app

You can find the source code of each project by clicking on the link in the header. Every project contains apps built with Xcode and contains a sample codemagic.yaml for you to run on Codemagic.

Upcoming Movies App by Alonso Alvarez

This iOS movies app is written in Swift 5 using the TMDB API, and it demonstrates:

  • Clean Architecture
  • Dependency injection
  • The Model-View-ViewModel (MVVM) pattern
  • Working with coordinators

Upcoming movies screen containing the list of movies.

The iOS Swift project also uses fastlane to run the unit tests and SwiftLint scans to enforce Swift’s style and conventions.

Going through this project can also help you understand how to use third-party libraries like Kingfisher for downloading and caching the images of the movies.

Then, KeychainSwift is used to securely save the signed-in user’s session ID and account ID in Keychain.

The GitHub project contains a sample codemagic.yaml file that you can use for building this open-source iOS project and running tests with Codemagic. If you’re not registered yet, sign up here:

Sign up

Clean Architecture for SwiftUI & Combine by Alexey Naumov

This demo project showcases how you can set up a native iOS/macOS app using the SwiftUI framework with Clean Architecture. The app uses the REST Countries API to show the list of countries and details.

Open source iOS app example that contains a list of countries

This project can help you understand how to:

  • Decouple the presentation, business logic, and data access layers
  • Have full test coverage, including the UI tests
  • Use a Redux-like centralized state container as the single source of truth
  • Persist data with Core Data
  • Manage dependency injection in a native SwiftUI app
  • Perform programmatic navigation and push notifications with deep linking
  • Create a simple yet flexible networking layer built on generics

Finally, this app is designed for scalability. You can use it as a reference for building large production apps.

If you want to learn more about the author’s thought process, you can read their article on Clean Architecture for SwiftUI.

The GitHub project contains a sample codemagic.yaml file that you can use for building this open-source iOS project and running tests with Codemagic.

TVShows iOS by Jeans Ruiz

This open-source iOS Swift project is built with RxSwift using the TMDB API. It is written using Swift 5 and uses Tuist to generate the workspace.

Breaking Bad details screen that is shown after searching for TV shows.

This project can help you learn how to use:

  • RxSwift, RxDataSources
  • Clean and Modular Architecture
  • The coordinator pattern
  • The MVVM pattern
  • Dependency injection

Apart from working with different third-party dependencies, this open-source iOS project introduces you to Tuist, a command-line tool that helps you generate, maintain, and interact with Xcode projects. The project and workspace are not committed to a Git repository. Instead, they are generated locally on your machine, which means no more Git conflicts!

The GitHub project contains a sample codemagic.yaml file that you can use to generate the project using Tuist and build it.

Template iOS App using Clean Architecture and MVVM by Oleh

This is a template iOS project implemented with Clean Layered Architecture and MVVM. You can use it in your project by replacing the “Movie” item.

The architectural concepts used here are:

  • Clean Architecture
  • MVVM pattern
  • Data binding using Observable without third-party libraries
  • Dependency injection
  • Flow coordinator
  • Data Transfer Object (DTO)
  • Response data caching
  • ViewController lifecycle behavior
  • SwiftUI and UIKit view implementations that reuse the same ViewModel
  • Error handling examples: in ViewModel and networking
  • CI pipeline (Codemagic + fastlane)

Open source iOS app example that shows clean architecture with MVVM pattern

This iOS Swift project also provides a great demonstration of how to have a good iOS project folder structure.

It is accompanied by an article on how architectural patterns such as MVVM and Clean Architecture can be applied in an iOS app. Clean Architecture and MVVM on iOS .

The GitHub project contains a sample codemagic.yaml file that you can use for running tests with Codemagic.

Modular Architecture on iOS by Oleh

This is a template iOS project implemented with Modular Architecture. You can use it in your project by replacing the “Movie” item.

As your iOS project grows, it gets difficult to maintain and manage it with several developers. The idea of modularization is that you break or split the app into different modules, like networking, authentication, and tracking, or even isolate large features in their own modules.

This means that if you are working on a large feature for an iOS project, you can work on it independently without building the whole app. For example, Spotify’s iOS app is highly modularized and has more than 400 independent modules!

Open source iOS app example that shows module dependencies

The accompanying article explains how the monolith OLX app was split into 12 modules. Modular Architecture in iOS.

The GitHub project contains a sample codemagic.yaml file that you can use for running tests using fastlane.

Conclusion

While you may or may not use the design patterns utilized in these open-source iOS projects, separating the UI, business logic, and data layers is a great practice in the long run.

We hope the projects mentioned in this article will help you learn more about Clean Architecture, modularizing your codebase as it grows bigger, and working with dependency injection. If you have any suggestions or feedback, join our Slack community or mention @codemagicio on Twitter!

Related articles

Latest articles

Show more posts