Config/buck_rule_macros.bzl, Config/buck_local.bzl, and Config/configs.bzl.
Library Macros
apple_lib
Defines an Apple library target with project-specific defaults.The name of the library target.
Visibility specification for the target.
Swift language version to use.
Whether to generate module maps.
Additional C/Objective-C compiler flags.
Additional Swift compiler flags.
Treat warnings as errors. Adds
-Werror and -warnings-as-errors flags. Automatically disabled for beta Xcode versions.Suppress all warnings. Adds
-w and -suppress-warnings flags.- Applies
library_configs()for build settings - Automatically disables
warning_as_errorwhen using Xcode beta - Merges custom flags with project defaults
Config/buck_rule_macros.bzl:101
apple_third_party_lib
Wrapper for third-party libraries with warnings disabled.- Calls
apple_libwithwarning_as_error=Falseandsuppress_warnings=True - Use for CocoaPods or vendor libraries that have warnings
Config/buck_rule_macros.bzl:5
apple_cxx_lib
Defines an Apple library with C++ support.Source files. Files with
.mm, .cpp, .S extensions are compiled with C++ flags.Extra linker flags beyond the defaults (
-lc++, -lz).- Automatically separates C++ sources (
.mm,.cpp,.S) from C/Swift sources - Applies C++ compilation flags from
.buckconfig - Adds
-wto suppress warnings in C++ code - Exports
-lc++and-lzlinker flags
Config/buck_rule_macros.bzl:222
apple_cxx_third_party_library
Wrapper for third-party C++ libraries.- Calls
apple_cxx_libwithwarning_as_error=Falseandsuppress_warnings=True
Config/buck_rule_macros.bzl:245
first_party_library
Comprehensive macro for first-party libraries with standardized structure.Library name. Creates three targets:
name, nameTests, nameTests-For-CI.Includes
Sources/**/*.m and Sources/**/*.h files.Includes C++ sources (
.cpp, .mm, .hpp) and uses apple_cxx_lib.Objective-C headers included in library but not exported.
Additional files to show in Xcode (e.g., README, scripts).
Generated Swift interfaces from CoreML models.
Host application for unit tests (required for application tests).
Additional frameworks for test target.
Additional dependencies for test target.
- Library Target
- Test Target
- CI Library Target
Target:
//MyLibrary:MyLibrary- Includes all sources from
Sources/ - Visible in Xcode projects
- Used by production code
Config/buck_rule_macros.bzl:148
Test Macros
apple_test_lib
Defines test targets with CI optimization.Test target name.
Create library target for CI optimization. Set to
false for the final CI test bundle.Whether this is a UI test target.
Target app bundle for UI tests.
Host application for unit tests.
Run this test in its own process.
Simulator destination override.
Labels for organizing tests.
name: apple_test bundle (runnable)name-For-CI: apple_library with test code (ifbundle_for_ci=True)
//Config:test_info_plist if not specified.
Source: Config/buck_rule_macros.bzl:23
apple_test_all
Bundles multiple test libraries into a single test target for faster CI.List of library names (without
Tests suffix). Automatically depends on {name}Tests-For-CI targets.Extra apple_test targets to include.
Prebuilt frameworks to include (workaround for Buck bug with transitive frameworks).
Config/buck_rule_macros.bzl:86
Resource & Code Generation
mlmodel_resource
Generates Swift interface and compiled CoreML model.Name for the generated Swift interface target. Include in library
srcs via mlmodel_generated_source.Name for the compiled .mlmodelc resource. Include in library
deps.Path to directory containing .mlmodel file. Must include trailing slash.
Name of .mlmodel file without extension.
Swift version for generated interface.
resource_source_name: Swift interface (.swift)resource_dependency_name_compiled_model: Compiled model (.mlmodelc)resource_dependency_name: Resource bundle containing compiled model
Config/buck_rule_macros.bzl:269
logging_genrule
Genrule wrapper that logs command execution.set -x; to enable verbose logging.
Source: Config/buck_rule_macros.bzl:253
BuckLocal Macros
BuckLocal enables hybrid Buck/Xcode development. These macros create dual targets for both modes.buck_local_binary
Creates binary targets for both native Xcode and BuckLocal modes.Binary name. Creates two targets:
name and nameBuckLocal.Dependencies for native Xcode target.
Dependencies for BuckLocal target.
Extra files for Xcode target.
Extra files for BuckLocal target.
Test targets (only applied to native Xcode binary).
- Uses
-exported_symbols_list /dev/nullto avoid symbol conflicts - Has no test targets
Config/buck_local.bzl:1
buck_local_bundle
Creates bundle targets for both modes.Bundle name. Creates
name and nameBuckLocal.Binary target name (without colon). Automatically appends
BuckLocal suffix for BuckLocal bundle.Resource dependencies for native Xcode bundle.
Resource dependencies for BuckLocal bundle.
Config/buck_local.bzl:26
buck_local_workspace
Creates workspace configurations for both modes.Workspace config name. Creates
name and name-buck-local.Xcode workspace name (without extension). BuckLocal adds
BuckLocal suffix.Main source target. BuckLocal automatically appends
BuckLocal suffix.UI test target (placed in extra_tests).
Scheme actions for native Xcode workspace.
Scheme actions for BuckLocal workspace.
Additional schemes for native Xcode workspace.
Config/buck_local.bzl:46
buck_local_apple_resource
Resource target with BuckLocal visibility.//BuckLocal: to visibility list.
Source: Config/buck_local.bzl:76
buck_local_apple_asset_catalog
Asset catalog with BuckLocal visibility.//BuckLocal: to visibility list.
Source: Config/buck_local.bzl:84
Configuration Helpers
Defined inConfig/configs.bzl and Config/utils.bzl.
library_configs
Returns build configurations for library targets.IPHONEOS_DEPLOYMENT_TARGET: 14.0SWIFT_WHOLE_MODULE_OPTIMIZATION: YESSKIP_INSTALL: YES (prevents generic archive issues)
Config/configs.bzl:48
app_binary_configs
Returns build configurations for app binaries.- All library configs
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES: YESPRODUCT_BUNDLE_IDENTIFIER: com.airbnb.-all_loadlinker flag (workaround for Swift bug SR-6004)
Config/configs.bzl:66
test_configs
Returns build configurations for test targets.Config/configs.bzl:77
watch_binary_configs
Returns configurations for watchOS binaries.SDKROOT: watchosWATCHOS_DEPLOYMENT_TARGET: 4.0WK_COMPANION_APP_BUNDLE_IDENTIFIER: com.airbnb.ExampleAppSWIFT_COMPILATION_MODE: wholemodule
Config/configs.bzl:112
message_binary_configs
Returns configurations for message extension binaries.Config/configs.bzl:127
config_with_updated_linker_flags
Adds linker flags to a config dictionary.- Appends flags if
OTHER_LDFLAGSexists - Creates
OTHER_LDFLAGSwith$(inherited)prefix if missing
Config/utils.bzl:60
configs_with_config
Creates a configs dictionary from a single config.Config/utils.bzl:33
Helper Functions
test_name
Generates test target name.test_name("MyLib") → "MyLibTests"
Source: Config/buck_rule_macros.bzl:12
ci_test_name
Generates CI library name for test code.ci_test_name("MyLib") → "MyLib-For-CI"
Source: Config/buck_rule_macros.bzl:14
bundle_identifier
Generates bundle identifier.bundle_identifier("MyApp") → "com.airbnb.MyApp"
Source: Config/configs.bzl:45
Constants
Default Swift version for all targets.Source:
Config/buck_rule_macros.bzl:17Development language for Info.plist.Source:
Config/configs.bzl:3Linker flag for binaries. Workaround for Swift bug SR-6004.Source:
Config/configs.bzl:43File extensions treated as C++ sources.Source:
Config/buck_rule_macros.bzl:221