Skip to main content
The LEAP Edge SDK provides native Swift integration for deploying LFM2 models on iOS devices. Built with SwiftUI support, the SDK handles model loading, inference, and streaming responses, making it straightforward to add on-device AI capabilities to your iOS applications.

iOS examples

The following examples demonstrate different use cases and capabilities of the LEAP SDK on iOS:

LeapChat

Full-featured chat app with real-time streaming, conversation management, and native SwiftUI interface

LeapSloganExample

Basic LEAP SDK integration for text generation demonstrating core SwiftUI patterns

Recipe Generator

Structured output generation with JSON schema validation

Audio Demo

Audio input and output processing with LEAP SDK for voice-enabled AI features

Example overview

ExampleDescriptionKey Features
LeapChatChat interface with streamingReal-time streaming, conversation management, SwiftUI
LeapSloganExampleText generationBasic SDK integration, SwiftUI patterns
RecipeGeneratorStructured outputJSON schema, formatted responses
Audio DemoAudio processingSpeech input/output, on-device inference

Getting started

All iOS examples are available in the LeapSDK-Examples repository. Each example includes:
  • Complete source code with Swift implementation
  • SwiftUI views and view models
  • Xcode project configuration
  • README with setup instructions
  • Sample prompts and usage examples

Installation

  1. Clone the LeapSDK-Examples repository:
    git clone https://github.com/Liquid4All/LeapSDK-Examples.git
    cd LeapSDK-Examples/iOS
    
  2. Open the example project in Xcode
  3. Follow the example-specific README for model setup and configuration

Basic integration

The LEAP SDK makes it easy to integrate LFM models into your iOS app. Here’s a basic SwiftUI example:
import LeapSDK
import SwiftUI

struct ContentView: View {
    @StateObject private var sdk = LeapSDK.shared
    @State private var response = ""
    
    var body: some View {
        VStack {
            Text(response)
            Button("Generate") {
                sdk.generateStream("Tell me a story") { token in
                    response += token
                }
            }
        }
        .onAppear {
            sdk.loadModel("lfm2-1.2b-instruct")
        }
    }
}

SwiftUI integration

The LEAP SDK is designed to work seamlessly with SwiftUI’s reactive patterns:
  • Use @StateObject or @ObservedObject for SDK instance management
  • Stream responses directly to @State properties for real-time UI updates
  • Leverage Swift’s async/await for model loading and inference
  • Combine with SwiftUI navigation for multi-screen chat experiences

Resources

Next steps

Build docs developers (and LLMs) love