Overview
This guide will walk you through building and running the ExampleApp using Buck. You’ll learn the basic Buck commands and workflows used in iOS development.Make sure you’ve completed the Installation steps before proceeding.
Basic Workflow
List available targets
View all build targets in the project:Or use Buck directly:You’ll see output listing all available targets:
Build the application
Build the ExampleApp target:This executes:Buck will:
- Parse all
BUCKfiles and build the dependency graph - Compile Swift and Objective-C source files
- Process resources (assets, strings, storyboards)
- Link libraries and create the final app bundle
Run the app in the simulator
Build, install, and launch the app in the iOS Simulator:This runs:Buck will:
- Build the app (if not already built)
- Launch the iOS Simulator
- Install the app on the simulator
- Launch the app automatically
The default simulator is iPhone 8. You can modify this in the
Makefile or run Buck directly with a different simulator:Additional Commands
Build for Release
Build with release configuration:Build Specific Extensions
Watch App
iMessage Extension
Clean Build Artifacts
Remove all build outputs:- Generated Xcode projects (
.xcworkspace,.xcodeproj) - Buck build outputs (
buck-outdirectory)
Working with Xcode
While Buck can build from the command line, you can also use Xcode for development.Generate Xcode Project
Run Tests in Xcode
Once you’ve generated an Xcode project:- Open the workspace:
App/ExampleApp-BUCK.xcworkspace - Select the
ExampleAppscheme - Press
Cmd + Uto run tests
Understanding Build Targets
The ExampleApp is composed of several targets:Main App Targets
//App:ExampleAppLibrary- Core application code (Swift/Objective-C)//App:ExampleAppBinary- Application binary//App:ExampleApp- Complete app bundle (binary + resources)
Library Targets
First-party libraries demonstrating different scenarios://Libraries/ASwiftModule:ASwiftModule- Pure Swift module//Libraries/Objc1:Objc1- Pure Objective-C module//Libraries/SwiftAndObjc:SwiftAndObjc- Mixed Swift and Objective-C//Libraries/SwiftWithAssets:SwiftWithAssets- Swift module with asset catalogs//Libraries/SwiftWithMLModel:SwiftWithMLModel- Swift module with CoreML model
Third-Party Dependencies
//Pods:CryptoSwift- CocoaPods dependency//Pods:PromiseKit- CocoaPods dependency//PrebuiltFrameworks:AFNetworking- Prebuilt framework
Visualizing Dependencies
Buck can generate a dependency graph for any target:ExampleAppBinary.
Common Workflows
Incremental Development
- Make code changes in your editor
- Run
make buildto compile - Run
make debugto test in simulator - Run
make testto verify tests pass
Buck automatically detects changes and only rebuilds affected targets. This makes incremental builds very fast.
Adding New Source Files
- Create your new
.swiftor.mfile - Add it to the appropriate
BUCKfile’ssrcsarray - Rebuild with
make build
Debugging Build Issues
If you encounter build errors:- Check the error message for the failing target
- Verify dependencies are correctly declared in
BUCKfiles - Try a clean build:
make clean && make build - Check Buck’s verbose output:
tools/buck build //App:ExampleApp -v 5
Next Steps
Now that you’ve built and run the app, explore these topics:- Build Targets - Learn how to define and configure Buck targets
- Dependencies - Understand dependency management and CocoaPods integration
- Configuration - Customize build settings and configurations
- Testing - Set up comprehensive test suites
Quick Reference
| Command | Description |
|---|---|
make install_buck | Install Buck build system |
make targets | List all build targets |
make build | Build the ExampleApp |
make debug | Build and run in simulator |
make test | Run unit tests |
make project | Generate Xcode project |
make clean | Clean build artifacts |
tools/buck --help | Show Buck CLI help |