What is Buck?
Buck is a fast build system that encourages the creation of small, reusable modules consisting of code and resources. It was designed to build multiple deliverables from a single repository and is optimized for building for multiple platforms.Core Concepts
Build Files
Buck usesBUCK files (or BUCK.bzl) to define build targets. These files are written in Starlark, a Python-like configuration language.
BuckSample uses Skylark syntax for build files, as configured in
.buckconfig with default_build_file_syntax = SKYLARK.App/BUCK
Rules
Rules are functions that define how to build a particular type of output. Buck provides built-in rules for different platforms and languages.- apple_library
- apple_binary
- apple_bundle
- apple_resource
Defines a library target containing Swift or Objective-C code:
App/BUCK
Targets
A target is an instance of a rule with specific parameters. Each target has a unique name within its BUCK file.Target names follow the pattern
//path/to/package:target_name. For example, //App:ExampleApp refers to the ExampleApp target in the App/BUCK file.Cells
Cells are independent Buck packages that can reference each other. In BuckSample, the main cells include://App:- The main application//Libraries:- First-party library modules//Config:- Build configuration and macros//Pods:- Third-party CocoaPods dependencies//PrebuiltFrameworks:- Prebuilt framework dependencies
Macros and Custom Rules
BuckSample uses custom macros to simplify common build patterns:Libraries/ASwiftModule/BUCK
first_party_library macro wraps the standard apple_library rule with common configuration.
Build Phases and Scripts
Buck supports Xcode build phase scripts for pre and post-build actions:App/BUCK
Build phase scripts are only executed when building with Xcode, not when building directly with Buck.
Visibility
Visibility controls which other targets can depend on a given target:Visibility Patterns
Visibility Patterns
"//App:"- Only targets in the App package"//App/..."- All targets in App and its subpackages"PUBLIC"- Any target in the project["//Foo:", "//Bar:"]- Multiple specific packages
Next Steps
Build Targets
Learn about Buck target patterns and naming conventions
Dependencies
Understand how to manage and visualize dependencies