Swift FavQs

Swift Platform Swift Package Manager

Unofficial iOS app client for FavQs API. I have been working on this project during my spare time and I’m using it mostly as a playground to play with Swift async/await and the latest version of TCA against a real-world API. It’s far from being production ready so many features are missing or not supported yet.

?️ Architecture

The application follows a clean architecture approach and exposes these layers:

  • Domain

    No dependencies, contains models and repository interfaces.

  • UseCase

    Very close to Domain and depends on Domain and swift-dependecies for repository registration and DI. It exposes a bunch of functions that can be called to execute the app use cases. Main reasons to have this layer are to have the screaming architecture part of the Domain and to avoid having features using directly the repositories.

  • Persistence

    This layer depends only on Domain and is the space for implementing the live repository interfaces.

    • Networking

      Implements the repository interfaces using URLSession and calls FavQs API. Internally maps DTOs with JSON details to Domain entities.

  • Presentation

    This layer exists only logically and contains other three sub-layers. Code in this layer depends on Domain, UseCase, and TCA. The sub-layers are:

    • Feature

      Contains the TCA reducers/features. This layer exists to reuse logic in both SwftUI and UIKit environments so no UI framework dependency is allowed.

    • SwiftUIPresentation

      Depends on Feature and has SwiftUI implementation of the UI.

    • UIKitImplementation

      Similar to SwiftUIPresentation but UIKit implementation of the UI.

  • Application

    The composition root. Contains the XCode project that depends on the other layers and exposes 2 targets to run the app using SwiftUI or UIKit presentation. It’s also the layer from where live repositories injection happens.

Architecture diagram

Generated using dependecy-graph.

? Getting Started

The only dependency that needs some manual steps is Arkana in the Networking implementation of the Persistence layer. You will need to install it and provide a FavQs API key in the Persistence/Sources/Networking/.env file (copy the existing .env.template and rename it) to use the live repositories implementation. Then run bundle exec arkana (from Persistence/Sources/Networking) and you should be good to go.

?‍? Contributing

Contributions are welcome, especially if you notice that I’m doing something completely wrong! If you would like to contribute feel free to raise issues or open pull requests.


View Github