Introducing MMBarricade

Post_20150602_MMBarricade_header

MMBarricade is a framework for setting up a runtime configurable local server that makes it easier to build and test network-driven iOS applications.

In today’s mobile market, nearly every app interacts with a web service to some degree, and many apps are completely dependent on information they access over the internet. In addition to the reliance on information from servers, there are several other factors complicating the relationship between apps and their APIs. The server-side component of an app is often developed by a different team, and at a different time than the client app. There are even times that portions of the app are built before the server-side work has even been started. From a development perspective, this makes web servers one of the single largest dependencies in any project.

Even when integrating with an existing server, there are many possibilities that must be considered. For example, let’s assume that we’re building an app for a company that sells stickers, and we have an API call that allows the app to search for stickers. When the app searches, there are several things that could happen: there could be no stickers, there could be a few stickers, or there could be thousands of stickers. Or, the server could be in maintenance mode or experiencing an unexpected outage. Beyond that, the user of our app could be on WIFI with a fast internet connection, struggling to hold a weak signal, or in the subway with no connection at all.

Each of these possibilities will be experienced by users, so a well-designed app should handle all of these situations gracefully. This presents a substantial challenge for development and QA teams, since many of these cases rely on server or network conditions which may be difficult to replicate on demand.

MMBarricade addresses these challenges by providing developers and testers with the ability to connect the app to a “local server” which allows them easily simulate the behavior of the server in each of these scenarios without the external dependency of a live server. In addition, it provides a “secret menu” (accessed by shaking the device) which allows the simulated response to be quickly changed.

screenshot

MMBarricade’s core functionality is made possible by Foundation’s URL Loading System, which allows developers to hook into their app’s network traffic just before it goes out to the Internet. This means that we can create a virtual barricade and redirect the network request to provide our own response without changing existing networking code.

We’ve been making use of this kind of solution at Mutual Mobile, and it has become a valuable part of our workflow for both developing and testing our apps. By decreasing external dependencies, we’ve been able to build higher quality apps with richer, more robust user experiences. We’re excited to share this with the broader iOS community and hope that you find it useful. Check it out on GitHub, and remember that pull requests are always welcome!

Stay-Up-To-Date

Keep in the loop with the latest in emerging technology and Mutual Mobile