Exchanger - a simple iOS application demonstrating one of approaches to implement VIPER 💎 architecture in modern Objective-C

Overview

Build Status

Exchanger

Exchanger

The Exchanger is a simple iOS application demonstrating one of approaches to implement VIPER 💎 architecture in modern Objective-C.

Table of contents

About

The application is a fairly straightforward currency converter. It takes a reference rate from a European Central Bank by parsing its public XML and provides a feature to exchange any currency including EUR, USD and GBP in any combination. The exchange rate is automatically updated each 30 seconds.

When app starts there is a limited balance with 100 units of each currency. There are two text inputs on the screen, both are cyclic carousel views for choosing currency to exchange.

YouTube video of how it works:

Exchanger app video

The app core is carefully designed with love ❤️ to SOLID in pure Objective-C using VIPER architecture combined with SOA. Meanwhile, unit tests are written in Swift.

If you have any questions just email me. Feel free to open issues 😀

Setup

CocoaPods

To install all project dependencies just use CocoaPods:

pod install

OCLint

If OCLint is not installed on your machine then run following commands in Terminal:

brew tap oclint/formulae
brew install oclint

XCPretty

If XCPretty is not installed on your machine then run following commands in Terminal:

gem install xcpretty

Notes on implementation

Architecture

The app is intended to implement the clean architecture.

Clean architecture

VIPER

Each screen is represented as VIPER module. In this implementation of VIPER there is a Router class for navigation between screens and functional callbacks to interact with module, for example:

@protocol ExchangeMoneyModule <NSObject>
@property (nonatomic, strong) void(^onFinish)();

- (void)dismissModule;

@end

Type Inference

Type Inference is a common feature in Swift, but Objective-C by default doesn't provide it. It's easy to avoid this issue by using C macroses, as it's provided below:

#define let __auto_type const
#define var __auto_type

Without using __auto_type:

NSArray
    *currencies = data.currencies;
  

With using using __auto_type:

let currencies = data.currencies;

Blocks

There is a common pattern in Objective-C to call a block:

if (block != nil) {
    block();
}

With optionals and closures syntax introduced in Swift this syntax looks especially overweighted. There is a C macros to deal with that:

#define safeBlock(block, ...) if (block != nil) { block(__VA_ARGS__); }

CarouselView

CarouselView implementation uses dummy UITextField in order to keep some first responder on the screen. It that way the keyboard is always on the screen which is a nice UX.

Persistance

App saves the state using simple Core Data storage.

Tests

Unit tests are provided for service layer and core layer including formatters. Some folks prefer to write unit tests for Presenter and Interactor. In practice it may be a case of accidental complexity. When business logic is located mainly in services, then unit tests for service layer are appropriate. Interactor just passes values from presenter to services. Presenter's code is often changing and it makes more sense to write UI tests. In this way unit tests for Interactor and Presenter are recommended but there is no strict need to write tests for them meanwhile code keeps to be testable and maintable.

You might also like...
A modern AppList alternative

AltList A modern AppList alternative The main focus of this dependency is to be an easy to use and easy to customize framework to handle per app prefe

[Accepted] My WWDC2021 Swift Student Challenge submission chosen as one of the 350 winners!
[Accepted] My WWDC2021 Swift Student Challenge submission chosen as one of the 350 winners!

Genetic Algorithms | WWDC21 This project was entirely built with SwiftUI. To direct download this Playground and run it on your Mac or IPad, click he

A sample iOS app built using the Clean Swift architecture

Main Purpose is to create a simple project for Clean-Swift This project wrote with using Clean-Swift and MVP Design Pattern

REDUX like architecture sample for iOS

perdux_sample_swiftUI REDUX like architecture sample for iOS (target 14.*) Motivation: to share reactive architecture approach with single direction d

Challenge-vip-delivery - Project for VIP (Clean Swift) Architecture Dev Sprints on Devpass
Challenge-vip-delivery - Project for VIP (Clean Swift) Architecture Dev Sprints on Devpass

VIP (Clean Swift) - Delivery App 🍕 Neste desafio, aplicaremos conceitos da arquitetura VIP para finalizar a implementação de um aplicativo. Desenvolv

The
The "Ask Me" is simple iOS application which shows answer on the screen everytime when the user press the ask button

The "Ask Me" is simple iOS application which shows answer on the screen everytime when the user press the ask button. This application is build and design by Chetan Parate using Xcode and Swift.

Simple Application that registers Vapor Leaf's .leaf file type to LaunchServices as html enabling automatic syntax highlighting in Xcode.
Simple Application that registers Vapor Leaf's .leaf file type to LaunchServices as html enabling automatic syntax highlighting in Xcode.

Vapor Leaf Extension Update: The Vapor Leaf Extension is now meant to be used with the Xcode Plugin I designed to provide Xcode language support for t

A simple application display album artwork from the iTunes API
A simple application display album artwork from the iTunes API

iTunesTestApp In the test task, you need to develop a simple application for the iPhone. The application should display album artwork from the iTunes

A simple application for watching movies
A simple application for watching movies

A simple application for watching movies

Comments
  • Correct the spelling of CocoaPods in README

    Correct the spelling of CocoaPods in README

    This pull request corrects the spelling of CocoaPods 🤓 https://github.com/CocoaPods/shared_resources/tree/master/media

    Created with cocoapods-readme.

    opened by ReadmeCritic 0
Owner
Vladimir Kaltyrin
Senior iOS Software Engineer & Software Engineering Consultant
Vladimir Kaltyrin
A demo project using VIPER architecture and building user interface programmatically

ProductDiscovery A demo project that building a UIKit user interface programmatically. Because the UI is made of code very long so I have separated it

Vinh Vo 7 Oct 1, 2021
Merqueo app uses VIPER architecture

merqueo-test How the app works Instalation This project require XCode 13.0, Swift 5.0 and should be run on device with iOS 15+ and then, you should ru

Brayam Mora 0 Oct 20, 2021
Demonstrating the use of a Sidebar, SplitView and Navigation styles in a multiplatform app.

Demonstrate the use of a Sidebar, SplitView, TabView and Navigation styles in a multiplatform app.

Russell Archer 12 Aug 24, 2022
SwiftUI project demonstrating how weak self works

SwiftUI-weak-self SwiftUI project demonstrating how weak self works Inspired by Swiftful

Standwerth 2 Oct 14, 2022
RestaurantMenu App Viper

RestaurantMenuAppViper В качестве открытого API используется https://www.themealdb.com/api.php (рецепты блюд) В связи с ограниченым функционалом данно

Ivan 0 Jan 14, 2022
Weather Forecast Assigment is an iOS application built to highlight MVP and Clean Architecture concepts

Weather Forecast Assigment - iOS - MVP + Clean Architecture Description Weather Forecast Assigment is an iOS application built to highlight MVP (Model

Khôi Việt 2 Oct 30, 2021
A simple iOS app with one default and four custom transitions.

A simple iOS app with one default and four custom transitions. The app uses the same two view controllers for every transition.

coding_o 7 Aug 18, 2021
This is a tiny experimental application using SwiftUI with Flux architecture.

?? SwiftUI-Flux This is a tiny experimental application using SwiftUI with Flux architecture.

Ryo Aoyama 52 Feb 6, 2022
NewsApp-MVVM - News application with MVVM architecture

NewsApp-MVVM News application with MVVM architecture.

Fırat Onurcan POLAT 1 Jan 29, 2022
A simple in iOS to demonstrate a basic MVVM architecture.

Repository A Simple iOS application in swift with MVVM-C architecture. Achitecture This project build on MVVM-C (Model, View, ViewModel, Coordinator)

Pankaj Kumar Jha 0 Oct 24, 2021