Migrating Our iOS Build System from Buck to Bazel

How Airbnb achieved a smooth and transparent migration from Buck to Bazel on iOS, with minimal interference to developer workflows

Qing Yang
9 min readintermediate
--
View Original

Overview

The article discusses Airbnb's migration of its iOS build system from Buck to Bazel, detailing the approach taken to ensure a smooth transition with minimal disruption to developer workflows. It covers the challenges faced, solutions implemented, and the benefits realized from adopting Bazel as a unified build tool across platforms.

What You'll Learn

1

How to leverage similarities between Buck and Bazel for build configuration

2

Why using a unified interface can minimize disruption during migration

3

How to implement a custom Xcode workspace generator using XcodeGen

4

When to transition from one build system to another without affecting developer workflows

Prerequisites & Requirements

  • Understanding of build systems and their configurations
  • Familiarity with Xcode and its integration with build systems

Key Questions Answered

What were the main challenges faced during the migration from Buck to Bazel?
The migration faced challenges due to differences in rules and parameters between Buck and Bazel, which required careful planning and the creation of a rules_shim layer to unify interfaces. Additionally, the distinct syntax for genrule scripts necessitated a unified approach to maintain compatibility across both systems.
How did Airbnb ensure minimal disruption to developer workflows during the migration?
Airbnb achieved minimal disruption by implementing a rules_shim layer that allowed for configuration sharing between Buck and Bazel, enabling engineers to continue using their existing workflows while transitioning. This approach facilitated the gradual migration without requiring immediate changes to the developers' day-to-day tasks.
What improvements were observed after migrating to Bazel?
Post-migration, Airbnb noted a 60% reduction in project generation time and over a 70% decrease in Xcode open time. These improvements significantly enhanced the developer experience, as reflected in internal surveys ranking the new workspace setup highly.
What tools were used to generate the new Xcode workspace?
Airbnb utilized XcodeGen, a tool that generates Xcode projects from YAML configuration, to create a workspace that closely mirrored their existing setup. This decision was made to ensure stability and compatibility during the transition to Bazel.

Key Statistics & Figures

Project generation time reduction
60%
This statistic reflects the improvement in efficiency after migrating to Bazel and using XcodeGen for workspace generation.
Xcode open time reduction
over 70%
This significant decrease indicates enhanced performance and responsiveness of the IDE post-migration.

Technologies & Tools

Build System
Bazel
Used as the new build system for iOS development at Airbnb.
Build System
Buck
The previous build system that was migrated away from.
Development Tool
Xcodegen
Used to generate Xcode projects from YAML configuration, facilitating the IDE integration.

Key Actionable Insights

1
Implement a rules_shim layer to manage differences between build systems effectively.
This approach allows for a unified interface that can help maintain compatibility during migrations, reducing the risk of disruption to developer workflows.
2
Consider using a tool like XcodeGen for generating Xcode projects to streamline workspace management.
Using XcodeGen can abstract away build system details, making it easier to manage projects and ensuring that IDE features remain intact during transitions.
3
Conduct thorough testing of new features in the target build system before fully transitioning.
This ensures that any issues can be identified and resolved without impacting the entire development process, allowing for a smoother migration.

Common Pitfalls

1
Failing to account for differences in build system rules can lead to significant migration challenges.
Without a clear strategy to address these differences, developers may face compatibility issues that disrupt workflows and slow down development.
2
Neglecting to test the new build system thoroughly before full deployment can result in unforeseen issues.
Proper testing ensures that any potential problems are identified early, allowing for a smoother transition and maintaining developer productivity.

Related Concepts

Build System Migration Strategies
Xcode Project Management
Continuous Integration With Bazel