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
- Buck treats modules as static libraries versus Xcode's dynamic frameworks
- The -import-underlying-module flag broke because Buck doesn't generate module maps
- Team created custom header map generation and transform scripts for *-Swift.h files
- Replaced @import with #import throughout generated code using automated scripts
- Open-sourced BuckSample project showing mixed-language library configuration
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.
About This Article
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.
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.
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.