Airbnb Brian Zhang Jul 1, 2017

Building Mixed Language iOS Projects with Buck

Article Summary

Brian Zhang from Airbnb's Mobile Developer Infra team cracked a problem that seemed impossible: getting Buck to build mixed Swift and Objective-C iOS projects. The payoff? 50% faster CI builds and 30% smaller app size.

Buck, Facebook's build system, didn't support mixed-language iOS projects—a dealbreaker for Airbnb's codebase with its even split of Swift and Objective-C. The team had to solve deep technical challenges around bridging headers, module maps, and how Buck's static linking approach differs fundamentally from Xcode's framework-based builds.

Key Takeaways

Critical Insight

Airbnb achieved 50% faster CI builds and 30% smaller app size by extending Buck to support mixed Swift/Objective-C projects through custom tooling for header maps and bridging.

The article reveals three remaining challenges the team is tackling, including why buck project for Xcode generation is still on their roadmap.

About This Article

Problem

Buck's static linking approach removed the module.modulemap and .hmap header map files that Swift's compiler needs. This broke the -import-underlying-module flag, which Xcode uses to implicitly import Objective-C headers in mixed-language modules.

Solution

Brian Zhang's team updated Buck to generate header maps for the Swift tool. They also added an objc_header_transform_script parameter to the apple_library rule. This allows automated replacement of @import directives with explicit #import statements in generated *-Swift.h files.

Impact

The BuckSample project shows how to configure mixed-language libraries using bridging headers and prebuilt rules for CocoaPods. Teams using this approach achieved a 50% CI build speedup and 30% app size reduction in Airbnb's production environment.