denissimon / iOS-MVVM-Clean-Architecture

Example iOS app designed using MVVM-C and Clean Architecture. Uses Swift Concurrency.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iOS-MVVM-Clean-Architecture

Swift Version Platforms License: MIT

Example iOS app designed using MVVM-C and Clean Architecture. Uses Swift Concurrency.

The app retrieves images for any search query or tag via the Flickr API. It has three MVVM modules: ImageSearch, ImageDetails, HotTags.

Architecture concepts used here

Includes

  • Reusable and universal NetworkService based on URLSession
  • Reusable and universal SQLite wrapper around SQLite3
  • Image caching service
  • Advanced error handling
  • Unit tests for a number of components from all layers

Main layers

Presentation Layer: coordinators, UI elements / views, storyboards, view controllers and ViewModels

Domain Layer: entities (or domain models), interfaces (for services and repositories) and domain services

Data Layer: services, entity repositories, API/DB interactors (or network services and storages) and adapters

Use cases

ImageSearch module:

* imageService.searchImages(imageQuery)
* imageCachingService.cacheIfNecessary(self.data.value)
* imageCachingService.getCachedImages(searchId: searchId)

ImageDetails module:

* imageService.getBigImage(for: self.image)

HotTags module:

* tagRepository.getHotTags()

Image caching service

ImageCachingService implements logic for caching images downloaded from Flickr. This helps keep the app's memory usage under control, since there can be a lot of downloaded images, and without caching, the app could quickly accumulate hundreds of MB of memory used. Downloaded images are cached and read from the cache automatically.

Reusable components from this project

  • SwiftEvents - the easiest way to implement data binding and notifications. Includes Event<T> and Observable<T>. Has a thread-safe version.
  • URLSessionAdapter - a Codable wrapper around URLSession for networking
  • SQLiteAdapter - a simple wrapper around SQLite3

Requirements

iOS version support: 15.0+. For app versions <= 1.2, iOS version support: 10.0+

Xcode 13.0+, Swift 5.5+

About

Example iOS app designed using MVVM-C and Clean Architecture. Uses Swift Concurrency.

License:MIT License


Languages

Language:Swift 100.0%