Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Ggml org Llama cpp Build XCFramework

From Leeroopedia
Knowledge Sources
Domains Build_System, Apple
Last Updated 2026-02-15 00:00 GMT

Overview

Shell script that builds an Apple XCFramework bundle containing llama.cpp libraries for iOS, macOS, tvOS, visionOS, and their simulator variants.

Description

This script is part of the llama.cpp build infrastructure and automates the creation of a multi-platform Apple XCFramework. It configures CMake builds for each Apple platform target (iOS device, iOS simulator, macOS, tvOS, visionOS) with Metal GPU support enabled and appropriate minimum OS versions. The script combines static libraries using libtool, sets up framework directory structures, and invokes xcodebuild -create-xcframework to produce the final bundle.

Usage

Run this script from the repository root to build an XCFramework for integrating llama.cpp into Swift or Objective-C Apple platform applications. Requires CMake and Xcode Command Line Tools to be installed.

Code Reference

Source Location

Signature

#!/usr/bin/env bash

# Key functions:
check_required_tool()          # Validates that a required CLI tool is available
setup_framework_structure()    # Creates the framework directory layout for a platform build
combine_static_libraries()     # Merges multiple .a files into a single library via libtool

Import

# Run from the repository root:
bash build-xcframework.sh

I/O Contract

Inputs

Name Type Required Description
IOS_MIN_OS_VERSION env/constant No Minimum iOS deployment target (default: 16.4)
MACOS_MIN_OS_VERSION env/constant No Minimum macOS deployment target (default: 13.3)
VISIONOS_MIN_OS_VERSION env/constant No Minimum visionOS deployment target (default: 1.0)
TVOS_MIN_OS_VERSION env/constant No Minimum tvOS deployment target (default: 16.4)

Outputs

Name Type Description
build-apple/ directory XCFramework output directory containing the multi-platform framework bundle
llama.xcframework bundle The final XCFramework usable in Xcode projects, containing libraries for all Apple platforms with Metal GPU acceleration

Usage Examples

# Build the XCFramework from the repository root
./build-xcframework.sh

# The resulting framework will be in build-apple/llama.xcframework
# Add it to your Xcode project as an embedded framework

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment