Connect with us


SwiftyMarvel: Clean Architecture + MVVM + Swinject + Async/Await + Unit Testing + Arkana + Mockingbird + CI Pipeline

SwiftyMarvel is a SwiftUI app that uses the Marvel API to display a list of Marvel characters and their details. You can browse through hundreds of heroes and villains from the Marvel universe, see their comics, and learn more about their powers and abilities.

This app is created as a personal project to showcase my skills and passion for iOS development. This app demonstrates how to implement Clean Architecture and some of best practices for iOS app development using SwiftUI, Combine, MVVM, Dependency Injection, Unit Testing, Code Coverage, and more.

Project Structure

This project uses Clean Architecture and is separated into four main layers:

  • Data: Contains the repositories implementations responsible for abstracting the data source used. In this case, the data source is a REST API, but it could be anything else, like a database, or cache.
  • Domain: Holds the business logic layer, which contains the use cases responsible for handling the business logic of the application and the abstract repositories. The use cases are the entry point to the domain layer.
  • Presentation: Contains the UI responsible for presenting the data to the user and handling user interactions. It also contains the ViewModels, which are responsible for preparing the data to be presented and for handling the interactions between the view and the use cases.
  • Core: Contains the common code between the other layers, like the extensions and the dependency injection code.

Folder Structure

┣ 📂Core
┃ ┣ 📂DI
┃ ┗ 📂Extensions
┣ 📂Data
┃ ┣ 📂Constants
┃ ┣ 📂DataSource
┃ ┣ 📂Model
┃ ┣ 📂Mappers
┃ ┣ 📂Networking
┃ ┗ 📂Repository
┣ 📂Domain
┃ ┣ 📂Entity
┃ ┣ 📂Errors
┃ ┣ 📂Repository
┃ ┗ 📂UseCase
┣ 📂Presentation
┃ ┣ 📂Core
┃ ┣ 📂ReusableViews
┃ ┣ 📂Screens
┃ ┃ ┣ 📂Home
┃ ┃ ┃ ┣ 📂ViewModels
┃ ┃ ┃ ┗ 📂Views
┗ 📜SwiftyMarvelApp.swift => The app entry point.

Tools & Frameworks Used

Tool Used for
MVVM Architectural design pattern for separating the logic form the views
Swinject Dependency Injection
Arkana Securely storing secrets and keys
Nuke Image Loading & Caching
SwiftLint Code Linting
Mockingbird Generating mock, stub, and verify objects in Swift unit tests

Development Environment

  • Xcode 14.3.1
  • Swift 5.8.1
  • iOS Deployment Target 16.2

CI Pipeline

This project uses GitHub Actions and Codecov to automate the building, testing, and code coverage analysis of the project. The CI pipeline runs whenever a new commit or pull request is made to the main branch.

SwiftyMarvel on GitHub:
Platform: iOS
⭐️: 64