Quick Start
The fastest way to build the app:ExampleApp target using Buck.
Build Commands
Build with release configuration
Build with optimizations enabled:This uses the Release.buckconfig file:
Build and Run
To build and install the app on the iOS Simulator:- Builds the app using Buck
- Installs it on the iPhone 8 simulator
- Launches the app automatically
The simulator name can be customized in the Makefile. The default is
iPhone 8.Build Configuration
Release Configuration
TheBuildConfigurations/Release.buckconfig file defines release-specific settings:
- Enable size optimizations (
-Osize) - Add the
RELEASESwift compiler flag - Configure the build for production use
Buck Binary
BuckSample uses a local Buck binary located attools/buck. This ensures consistent builds across all developers.
Build Targets
BuckSample includes multiple build targets defined inApp/BUCK:
| Target | Description | Command |
|---|---|---|
//App:ExampleApp | Main iOS app bundle | make build |
//App:ExampleAppLibrary | Core app library | tools/buck build //App:ExampleAppLibrary |
//App:ExampleAppBinary | App binary | tools/buck build //App:ExampleAppBinary |
//App:ExampleWatchApp | Watch app | make watch |
//App:ExampleMessageExtension | iMessage extension | make message |
//App:ExampleWidgetExtension | Widget extension | tools/buck build //App:ExampleWidgetExtension |
Listing All Targets
To see all available Buck targets in the project:Build Architecture
App Structure
The app uses a modular architecture with Buck:- ExampleAppLibrary (
App/BUCK:58-86): Contains the main app code (ViewControllers, AppDelegate) - ExampleAppBinary (
App/BUCK:88-104): Links the library into a binary - ExampleApp (
App/BUCK:149-168): Bundles the binary with resources
Dependencies
The app depends on:- First-party libraries: Custom Swift/Objective-C modules in
//Libraries - CocoaPods: External dependencies like CryptoSwift and PromiseKit
- Prebuilt frameworks: AFNetworking and other precompiled frameworks
- Resources: Asset catalogs, storyboards, and localized strings
Build Extensions
Watch App
The Watch app consists of two parts:- ExampleWatchApp: The watch application itself
- ExampleWatchAppExtension: The code that runs on iPhone
Watch apps must be defined in the same BUCK file as the main app due to Xcode’s requirements for embedding watch apps.
iMessage Extension
The message extension enables iMessage integration:- Set the entry point to
_NSExtensionMain - Configure the rpath to find frameworks in the main app bundle
Widget Extension
Build the widget extension:Build Output
Buck stores all build artifacts in thebuck-out/ directory at the repository root. The directory structure:
Troubleshooting
Build Failures
If the build fails:- Clean the build:
make clean && make build - Update CocoaPods:
make update_cocoapods - Reinstall Buck:
make install_buck - Check Buck version:
tools/buck --version
Common Issues
Problem: “Buck command not found”- Solution: Run
make install_buckto download the Buck binary
- Solution: Ensure CocoaPods are installed:
pod install
- Solution: Update the
TARGET_SIMULATORvariable in the Makefile to match an available simulator
Next Steps
Running Tests
Learn how to run unit tests and UI tests with Buck
Xcode Integration
Generate Xcode projects from Buck for IDE development