GhosttyKit

Swift package for embedding Ghostty’s terminal emulator library in Apple apps. Native SwiftUI, UIKit, and AppKit views wrap a pre-built libghostty XCFramework.

Capabilities

Install

Add the package to Package.swift:

dependencies: [
    .package(url: "https://github.com/Lakr233/libghostty-spm.git", from: "1.2.0"),
],
targets: [
    .target(name: "App", dependencies: [
        .product(name: "GhosttyTerminal", package: "libghostty-spm"),
    ]),
]

Choose the product that matches the integration layer you need.

ProductUse
GhosttyKitDirect access to the ghostty.h C API.
GhosttyTerminalSwift wrapper, native views, configuration, input, display link, host-managed I/O.
GhosttyThemeBundled terminal color schemes and bridges to TerminalConfiguration.
ShellCraftKitSandboxed shell emulation on top of GhosttyTerminal.

Platforms

PlatformFloor
iOS15.0
macOS13.0
Mac Catalyst15.0

Quick start

import SwiftUI
import GhosttyTerminal

struct ContentView: View {
    @StateObject private var terminal = TerminalViewState()

    private let session = InMemoryTerminalSession(
        write: { data in
            // Bytes from Ghostty to your host process or emulator.
        },
        resize: { viewport in
            // Keep your backend grid in sync with Ghostty.
        }
    )

    var body: some View {
        TerminalSurfaceView(context: terminal)
            .navigationTitle(terminal.title)
            .onAppear {
                terminal.configuration = TerminalSurfaceOptions(
                    backend: .inMemory(session)
                )
            }
    }
}

InMemoryTerminalSession.receive(_:) writes host output into the terminal. The write closure receives terminal input bytes for your backend.

Examples