Build a Foursquare clone iOS app — Part 1: Introduction and setup

Content

Introduction

In this article I want to show how to build a scalable iOS application by using concepts like continuous integration and state management. We will also aim for a good object-oriented design to make sure the code can be tested properly.

The app will make use of user location and show the nearby places of interests using the Foursquare API.

This won’t be a detailed step by step tutorial because I will focus more on architectural and automated tests, so the full understanding of this article will require a basic knowledge of iOS programming. Check the final code at the Github repository for full understanding.

If you want to follow the Continuous Integration (CI) step, it’s recommended that you use a free Github account as a version control system.

Motivation

I’ve decided to build this application to study and share some technical concepts applied to the Swift/iOS environment:

  • Protocol-Oriented Programming
  • Dependency Injection
  • State management
  • Reactive Programming
  • Continuous Integration

Despite of the complexity of the concepts above, I want this series of articles to be applicable and easy to follow.

Keep in mind that these concepts may not be needed in a real project with an small scope like the one we’re building. Pay attention to not overengineer.

Project setup and main requirements

This project was started using:

  • Xcode 9.2
  • Swift 4.0
  • Deployment target: iOS 9.0
  • Ruby 2.3.4
  • Cocoapods 1.3.1
  • Core Location framework

External dependencies

Below are the libraries defined at Podfile and why I have decided to use them:

  • Swinject : for decoupling our classes from instantiating its own dependencies and making it easier to provide mock instancies for unit tests. No special reason for choosing this instead of another similar solution.
  • RxSwift: besides the data manipulation and the ability to easily switch between main and background threads, reactive programming turns your application easier to reason about.
  • ReSwift: it provides an unidirectional data flow architecture inspired by Redux
  • Hero: for displaying the data in a beautiful interface
  • SwiftLint: ensure you code follows an unique convention
  • Moya to handle our HTTP Requests and Moya-ModelMapper to parse the JSON response into Swift objects.
  • Kingfisher: to display images from URLs into UIImageView

Conclusion

Finishing the setup of the project, I’ve decided in no particular order to start developing the data layer of the application.

Next part: Location data and managing dependencies