Flutter Embedder for libghostty.
Taking reference from https://github.com/ghostty-org/ghostling.
All code is written here by AI.
- macOS (currently the only supported platform)
- Zig 0.15.2 - Required for building libghostty
- Flutter SDK
- Xcode Command Line Tools
git clone --recursive https://github.com/jiahaog/flutter_ghostty.git
cd flutter_ghosttyIf you've already cloned without --recursive, fetch the submodules:
git submodule update --init --recursiveInstall Zig version 0.15.2 and ensure it is on your PATH.
flutter pub getflutter run -d macos and flutter build macos invoke the package build hook
in hook/build.dart. That hook calls scripts/build_native_deps.sh to:
- build
libghostty-vtviazig build lib-vt -Demit-macos-app=false - build the PTY helper (
libpty.dylib) via clang - bundle both libraries as native assets for the macOS app
No custom macOS Xcode build phase or manual runpath setup is required.
flutter run -d macosTo produce a release build:
flutter build macosRegenerate the Ghostty bindings when ghostty/vt.h changes:
dart run ffigen --config ffigen.yamlNative dependency orchestration now lives in Dart hooks and native assets, not in custom macOS Runner build phases.
flutter run -d macosandflutter build macosinvokehook/build.darthook/build.dartdetects the target platform and architecture, then runsscripts/build_native_deps.shscripts/build_native_deps.shbuildslibghostty-vtvia Zig andlibptyviaxcrun clang- the hook emits bundled
CodeAssets for the Dart libraries that declare the native bindings
lib/src/ghostty_bindings.g.dartis generated withffigeninffi-nativemode, so Ghostty symbols are declared with@ffi.Nativelib/src/pty_ffi.dartalso uses@Nativedeclarations instead ofDynamicLibrary.open(...)- the hook emits assets named after those Dart library URIs, so Dart resolves symbols through Flutter's native-assets manifest at runtime
lib/src/terminal_state.dartcan call the bindings directly without platform-specific loading code
Flutter macOS apps still build through an Xcode host project, so
macos/Runner.xcodeproj remains. The difference is that the project no longer
owns the native dependency setup:
- the old custom Runner shell phase is removed
- custom linker flags and runpath tweaks are removed
- the remaining Flutter assemble wiring is standard Flutter host-project logic
When Android, iOS, or Linux support is added later, the main extension point is
still hook/build.dart. New platform branches can emit the same asset IDs for
platform-specific binaries, while the Dart binding and terminal code stays the
same.
You can still build the native libraries directly without launching Flutter. The compatibility wrapper remains available:
./scripts/build_libghostty.shFor direct access to the generalized script and its options:
./scripts/build_native_deps.sh --helpManual builds default to writing artifacts under build/native/macos/.