Testing Core Data integration in your app is very useful and a lot easier than you think! In this post we show you how we create a test Core Data stack in Tiendeo and the basics for testing predicates, fetches, deletes and saves.

Create a test Core Data stack

We just need to set up the NSPersistentContainer as we usually do, but we don’t want to persist the data in disk but in-memory.

The in-memory data is cleaned as soon as the persistentContainer deinits and a new persistentContainer instance created will be start from zero, which is perfect for testing!

To achieve this, there are actually…


In a previous post we had the opportunity to define the architecture of our app conceptually. The purpose of this post is to get deep into implementation of key components of this architecture we’re using.

In this post we’ll talk about how we implement:

Repository pattern

Repository pattern is a software design pattern that provides an abstraction of data, so that your application can work with a simple abstraction that has an interface. Using this pattern can help achieve loose coupling and can keep domain objects persistence ignorant.

It also makes code more testable as it allows us to inject as a…


In a previous post we had the opportunity to define the architecture of our app conceptually. The purpose of this post is to get deep into implementation of key components of this architecture we’re using.

In this post we’ll talk about how we implement:

RxSwift + clean architecture

Our app uses ReactiveX swift version: RxSwift. RxSwift is a powerful tool to compose asynchronous operation and event/data streams. These streams make easy the communication between layers. That’s why we think that it fits perfectly to our architecture demands.

The way RxSwift streams through the different layers of our architecture is represented in this scheme:

Basically…


In a previous post we had the opportunity to define the architecture of our app conceptually. The purpose of this post is to get deep into implementation of key components of this architecture we’re using.

In this post we’ll talk about how we implement:

Dependency injection

I think that this quote by James Shore defines what dependency injection is:

Dependency injection means giving an object its instance variables. Really. That’s it.

Dependency injection is a software design pattern that helps you to make the code more testable reducing the coupling.

Habitually dependency injection pattern is confronted to singleton pattern. In my opinion…


In 2017 Tiendeo mobile department faced a huge challenge: remake the app from the scratch.

Our legacy app was created on 2013. It was build with simple MVC architecture, Objective-C (of course), it used RestKit, AFNetworking and so many other pods… After years of development and a few developers, it became huge, unscalable, unstable, with massive view controllers, massive AppDelegate, some new features were coded in Swift, some refactorized part as well, so we had few Swift-Objective-C bridges, … it was a monster that ate children for breakfast.

Considering all these issues plus some changes in business orientation, the company…


The purpose of this post is to explain how we handle the authentication flow in our authentication framework.

Our auth framework uses Alamofire for HTTP networking, AlamofireObjectMapper for serialize the HTTP responses and our web services are behind an OAuth authentication system.

If you’re familiar with Alamofire advanced usage, we use a custom Alamofire SessionManager class (+info), called AuthenticationSessionManager, that implements Alamofire RequestAdapter and RequestRetrier protocols (+info).

Basically, RequestAdapter allows you to append an Authorization header to each request made with your custom SessionManager class. …


In Tiendeo Mobile department we’re always looking for new ways to make our app more testable and our tests better.

Let me introduce basic concepts about our data layer. If you are familiar with Alamofire and AlamofireObjectMapper, our app data layer uses a custom Alamofire SessionManager class, called AuthenticationSessionManager, that implements RequestAdapter and RequestRetrier protocols.

Our AuthenticationSessionManager has its own request method to check if user token is valid before call the Alamofire request method:

For further information about how we handle the authentication flow, have a look to other of my post. 😉

In purpose to test the…

Raul Peña Alonso

iOS developer established in 2012

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store