BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Building Large-Scale iOS Apps at Airbnb

Building Large-Scale iOS Apps at Airbnb

This item in japanese

The Airbnb iOS team addressed the challenge of its growing mobile app codebase and complexity by adopting new tools and processes, including a modern build systems, module types, and dev apps.

The first hurdle the Airbnb team had to circumvent was Xcode slowness, especially when indexing files and building code, and its "unfriendliness" to code versioning systems:

Not only are Xcode project files challenging to review in pull requests, but the incidence of merge conflicts and race conditions in these project files increased with a larger team of engineers moving at a high velocity.

Xcode is very powerful and provides an unmatched level of integration with iOS and other tools by Apple, but it lacks a few features that were key to Airbnb engineers, such as a network cache for build artifacts, a query interface for the build graph, and a way to add custom steps as dependencies.

To deliver all these features to developers, Airbnb chose Facebook Buck, a build system based on the same Starlark language used by Google's Bazel. Buck allows to generate Xcode workspaces from a declarative build graph, thus ensuring a level of optimal integration with the iOS development ecosystem. Instead of using Xcode native build system, which is not able to take advantage of artifact caching, Airbnb extended Buck so it generates Xcode projects that seamlessly invoke Buck for the build. This makes the build step up to 5-6 times faster when Buck HTTP cache is enabled.

Besides improving their infrastructure, Airbnb engineers designed a discovery-oriented organizational structure for their codebase by organizing modules into groups called module types. Each module type has a set of visibility rules that define which dependencies are allowed between modules of that type.

For example, a module type is a feature, which is a UIViewController, which may include child UIViewControllers but not other features. Features can only communicate with one another through feature interface, which is another module type with broader visibility.

According to Airbnb engineers, module types act as a table of contents for they entire codebase and immediately convey their meanings.

A third innovation to Airbnb iOS infrastructure is Dev Apps, which are on-demand, ephemeral Xcode workspace for a single module and its dependencies.

The popularity and success of both Android and iOS Dev Apps derive from a simple axiom: minimizing your IDE scope to only the files that you are editing tightens the development loop.

Dev Apps are generated using a command line tool which uses Buck to find out which files are required to build a requested module. The tool also generates a container app that hosts the feature and makes it runnable. Most Dev Apps can be built in less than two minutes, say Airbnb engineers.

This overall approach, which led to defining nearly 1,500 modules, also made it possible to effectively enforce code ownership and improve test coverage.

Airbnb approach to building iOS apps at scale involves much more than can be covered here, so do not miss the original write up if you are interested.

Rate this Article

Adoption
Style

BT