Skip to main content
The BuckSample project uses Make to provide convenient build automation. All commands use the local Buck binary at tools/buck.

Build Commands

Builds the main ExampleApp target for development.
make build
Implementation:
$(BUCK) build //App:ExampleApp
Use case: Standard development builds with debug configuration.
Builds the ExampleApp target with release configuration.
make build_release
Implementation:
$(BUCK) build //App:ExampleApp --config-file ./BuildConfigurations/Release.buckconfig
Use case: Production builds with optimizations enabled.
Builds the watchOS app extension.
make watch
Implementation:
$(BUCK) build //App:ExampleWatchAppExtension#watchsimulator-i386
Use case: Building the watchOS companion app.
Builds the iMessage extension.
make message
Implementation:
$(BUCK) build //App:ExampleMessageExtension
Use case: Building the iMessage app extension.

Installation & Setup

Downloads and installs the Buck build tool.
make install_buck
Implementation:
curl https://jitpack.io/com/github/airbnb/buck/f2865fec86dbe982ce1f237494f10b65bce3d270/buck-f2865fec86dbe982ce1f237494f10b65bce3d270-java11.pex --output tools/buck
chmod u+x tools/buck
Use case: First-time setup or updating Buck version.
Updates CocoaPods repository and installs dependencies.
make update_cocoapods
Implementation:
pod repo update
pod install
Use case: Updating third-party dependencies managed by CocoaPods.
Installs Ruby dependencies using Bundler.
make install_ruby_gems
Implementation:
bundle install --path vendor/bundle
Use case: Installing Ruby tools needed for BuckLocal and testing.

Testing Commands

Runs unit tests with code coverage reporting.
make test
Implementation:
@rm -f $(buck_out)/tmp/*.profraw
@rm -f $(buck_out)/gen/*.profdata
$(BUCK) test //App:ExampleAppCITests --test-runner-env XCTOOL_TEST_ENV_LLVM_PROFILE_FILE="$(buck_out)/tmp/code-%p.profraw%15x" \
    --config-file code_coverage.buckconfig
xcrun llvm-profdata merge -sparse "$(buck_out)/tmp/code-"*.profraw -o "$(buck_out)/gen/Coverage.profdata"
xcrun llvm-cov report "$(TEST_BUNDLE)/ExampleAppCITests" -instr-profile "$(buck_out)/gen/Coverage.profdata" -ignore-filename-regex "Pods|Carthage|buck-out"
Features:
  • Runs CI test bundle
  • Generates code coverage data (.profraw files)
  • Merges coverage data into .profdata
  • Generates coverage report
  • Excludes third-party code (Pods, Carthage, buck-out)
Variables used:
  • buck_out: Buck’s output directory
  • TEST_BUNDLE: Path to test bundle from buck targets --show-output
Runs XCUITest tests on iOS Simulator.
make ui_test
Implementation:
$(BUCK) build //App:XCUITests
rm -rf ${UI_TESTS_TMP}
mkdir -p ${UI_TESTS_TMP}
ln -sf $(buck_out)/gen/App/XCUITests#apple-test-bundle,dwarf,no-include-frameworks,no-linkermap/XCUITests.xctest $(UI_TESTS_TMP)
cp $(UI_TESTS_TOOLS)/ExampleApp.xctestrun $(UI_TESTS_TMP)
unzip $(UI_TESTS_TOOLS)/XCUITests-Runner.app.zip -d $(UI_TESTS_TMP)
xcrun simctl boot $(TARGET_SIMULATOR) || true
xcrun simctl install $(TARGET_SIMULATOR) $(UI_TESTS_TMP)/XCUITests.xctest/PlugIns/ExampleApp.app
xcodebuild test-without-building -xctestrun $(UI_TESTS_TMP)/ExampleApp.xctestrun -destination 'platform=iOS Simulator,name=$(shell echo $(TARGET_SIMULATOR)),OS=latest'
Configuration:
  • TARGET_SIMULATOR: iPhone 8 (default)
  • UI_TESTS_TMP: Build directory for UI tests
  • UI_TESTS_TOOLS: Tools directory for test runner
Steps:
  1. Builds XCUITests bundle
  2. Prepares test environment
  3. Boots simulator
  4. Installs test app
  5. Runs tests using xcodebuild
Runs tests through Xcode workspace (requires project generation).
make xcode_tests
Implementation:
xcodebuild build test -workspace App/ExampleApp-BUCK.xcworkspace -scheme ExampleApp -destination 'platform=iOS Simulator,name=iPhone 8,OS=latest' | xcpretty && exit ${PIPESTATUS[0]}
Dependencies: Runs make project first to generate workspace.Use case: Testing via Xcode’s native test runner.
Runs Ruby-based tests for BuckLocal scripts.
make ruby_test
Implementation:
buck_binary_path=tools/buck bundle exec rspec BuckLocal/ruby_scripts/ -I BuckLocal/ruby_scripts/
Use case: Testing BuckLocal Ruby automation scripts.

Project Generation

Generates and opens the Xcode workspace.
make project
Implementation:
$(BUCK) project //App:workspace
open App/ExampleApp-BUCK.xcworkspace
Steps:
  1. Runs make clean to remove old projects
  2. Generates new Xcode workspace from Buck targets
  3. Opens workspace in Xcode
Use case: Working with Xcode IDE while using Buck as build system.
Generates BuckLocal workspace for hybrid Buck/Xcode development.
make buck_local_project
Implementation:
bundle exec rake buck_local:generate_project buck_binary_path=$(BUCK) workspace_target='//App:workspace-buck-local' top_level_lib_target='//App:ExampleAppLibrary' xcworkspace='App/ExampleAppBuckLocal-BUCK.xcworkspace'
open App/ExampleAppBuckLocal-BUCK.xcworkspace
Steps:
  1. Runs make clean
  2. Generates BuckLocal workspace using Ruby rake task
  3. Opens BuckLocal workspace
Use case: Hybrid development mode combining Buck’s speed with Xcode’s editing features.

Debugging & Running

Installs and runs the app on iOS Simulator.
make debug
Implementation:
$(BUCK) install //App:ExampleApp --run --simulator-name 'iPhone 8'
Features:
  • Installs debug build
  • Launches app automatically
  • Uses iPhone 8 simulator
Use case: Quick testing during development.
Installs and runs release build on iOS Simulator.
make debug_release
Implementation:
$(BUCK) install //App:ExampleApp --run --simulator-name 'iPhone 8' --config-file ./BuildConfigurations/Release.buckconfig
Use case: Testing release builds before distribution.

Utility Commands

Lists all Buck targets in the project.
make targets
Implementation:
$(BUCK) targets //...
Output: Shows all buildable targets in the repository.Use case: Discovering available build targets.
Generates Python representations of BUCK files.
make audit
Implementation:
$(BUCK) audit rules App/BUCK > Config/Gen/App-BUCK.py
$(BUCK) audit rules Pods/BUCK > Config/Gen/Pods-BUCK.py
Output: Creates Python files in Config/Gen/ showing parsed BUCK rules.Use case: Debugging Buck configuration and understanding rule expansion.
Generates and visualizes the dependency graph.
make dependency_graph
Implementation:
$(BUCK) query "deps(//App:ExampleAppBinary)" --dot > result.dot && dot result.dot -Tpng -o result.png && open result.png
Steps:
  1. Queries all dependencies of ExampleAppBinary
  2. Outputs GraphViz .dot format
  3. Converts to PNG using dot command
  4. Opens visualization
Requirements: GraphViz must be installed (brew install graphviz).Use case: Understanding and optimizing build dependencies.
Removes generated files and Buck output.
make clean
Implementation:
rm -rf **/*.xcworkspace
rm -rf **/*.xcodeproj
$(BUCK) clean
Removes:
  • All Xcode workspaces
  • All Xcode projects
  • Buck’s build output (buck-out/)
Use case: Fresh builds or resolving build issues.
Force quits Xcode and Simulator.
make kill_xcode
Implementation:
killall Xcode || true
killall Simulator || true
Use case: Resolving Xcode locks or hung processes.

CI Commands

Runs complete CI pipeline.
make ci
Implementation:
install_buck install_ruby_gems targets build test ui_test ruby_test project xcode_tests watch message
Steps (in order):
  1. install_buck - Install build tool
  2. install_ruby_gems - Install Ruby dependencies
  3. targets - Verify all targets are valid
  4. build - Build main app
  5. test - Run unit tests with coverage
  6. ui_test - Run UI tests
  7. ruby_test - Run Ruby tests
  8. project - Generate Xcode project
  9. xcode_tests - Run tests via Xcode
  10. watch - Build watch extension
  11. message - Build message extension
Use case: Continuous integration and comprehensive validation.
Simple test command that prints “Make”.
make log
Implementation:
echo "Make"
Use case: Verifying Make is working.

Variables

The Makefile defines several variables used throughout:
BUCK
string
default:"tools/buck"
Path to the local Buck executable.
buck_out
string
Buck’s output directory, resolved via $(BUCK) root.
TEST_BUNDLE
string
Path to the test bundle, resolved via buck targets --show-output.
UI_TESTS_TMP
string
Temporary directory for UI test artifacts: $(buck_root)/build/xcuitest.
UI_TESTS_TOOLS
string
Directory containing UI test tools: $(buck_root)/tools/xcuitest.
TARGET_SIMULATOR
string
default:"iPhone 8"
iOS Simulator device for testing.

Build docs developers (and LLMs) love