Clone this repo:


  1. dffa931 Point to the correct options file. by P.Y. Laligand · 5 days ago master
  2. 2560af0 Correct Rust build instructions by Todd Eisenberger · 8 days ago
  3. dea0297 Follow Flutter Point->Offset migration by Raph Levien · 8 days ago
  4. 7ae95f0 Rename widget in xi See upstream: by Xiao Yu · 2 weeks ago
  5. 8d7ea00 Update to the new ErrPeerClosed error name by George Kulakowski · 13 days ago

Xi Editor for Fuchsia

This repository contains the Fuchsia front-end for xi editor.

The back-end, or core (modules/xi-core) is basically the same as for the main xi editor, except that it is invoked through fidl and uses Magenta sockets for communication (still using a json-rpc based protocol, though that may evolve in the future). The front-end is written in Flutter.

Status: Experimental

What exists here mostly boilerplate for the tooling and infrastructure needed to build out the UI as a set of Flutter Widgets that can be run on Fuchsia.


This repo contains code for running a vanilla Flutter application (iOS & Android) and a Fuchsia specific set of modules.

  • modules: Fuchsia specific application (module) code.
    • xi-core: Xi core is a Rust binary built with a Fuchsia specific rustc (instructions below). A JSON protocol is used to communicate between Xi Core and the Xi UI.
  • packages: Platform agnostic Dart code separated into pub packages.
    • widgets: UI code is defined as a set of Flutter Widgets that can be imported and used in either Fuchsia Modules or the vanilla Flutter application.
  • services: FIDL service definitions.
  • xi_flutter: A vanilla Flutter application that uses the shared Dart packages and can be run on iOS or Android.


NOTE: Your checkout of Xi (fuchsia/xi) needs to be part of the Fuchsia source tree for any of these instructions to work.


Follow the instructions for setting up a fresh Fuchsia checkout. Once you have the jiri tool installed and have imported the default manifest and updated return to these instructions.

There is an optional, Rust specific manifest that needs to be added with:

jiri import rust

Then add/update the Rust projects to your Fuchsia tree with:

jiri update

Don't forget to set up the Fuchsia environment helpers in scripts/

source scripts/

Rust Toolchain

NOTE: This step is temporary.

A custom rustc build is required before Xi core can be built for Fuchsia. Start by building the clang wrapper in [magenta-rs][]:

export RUST_TOOLS=${FUCHSIA_DIR}/rust/magenta-rs/tools
clang++ -O --std=c++11 -o clang_wrapper
ln -s clang_wrapper x86-64-unknown-fuchsia-ar
ln -s clang_wrapper x86-64-unknown-fuchsia-cc
ln -s clang_wrapper aarch64-unknown-fuchsia-ar

You can sanity-check the clang wrapper:

clang-4.0: error: no input files

Then clone and build Rust per the magenta-rs docs:

export RUST_ROOT=${FUCHSIA_DIR}/third_party/rust
git clone $RUST_ROOT

Create a config file:

cat - <<EOF >$RUST_ROOT/config.toml
# Config file for fuchsia target for building Rust.
# See \`src/bootstrap/config.toml.example\` for other settings.

# Disable backtrace, as it requires additional lib support.
backtrace = false

cc = "${RUST_TOOLS}/x86-64-unknown-fuchsia-cc"

# Path to the clang wrapper
cc = "${RUST_TOOLS}/aarch64-unknown-fuchsia-cc"

Configure and build rustc (this will take a while):

./configure --target=x86_64-unknown-fuchsia
./ build --stage 1

Verify Rust Build

Build the magenta examples:

cd $FUCHSIA_DIR/rust/magenta-rs/

Configure cargo for the fuchsia target:

mkdir .cargo
cat - <<EOF >.cargo/config
linker = "${RUST_TOOLS}/x86-64-unknown-fuchsia-cc"

Build the magenta-rs example mx_toy:

RUSTC=${RUST_ROOT}/build/x86_64-apple-darwin/stage1/bin/rustc cargo build --target=x86_64-unknown-fuchsia --example mx_toy

The command above should succeed and generate a rust binary in the target dir.


Before the xi-core module can be built the fidl service should be built, this can be done by commenting out "//apps/xi/modules", in the apps/xi/ and then running:

fset x86-64 --modules default,rust
fgen -m=default,rust

This will error but it will generate the artifacts needed to continue.

Configure xi-core for building with the Fuchsia Rust toolchain. First:

fgo apps/xi/modules/xi-core
mkdir .cargo

Then create a configuration file with:

cat - <<EOF >.cargo/config
linker = "${RUST_TOOLS}/x86-64-unknown-fuchsia-cc"

Build the Rust binary for Xi core using the new rustc:

RUSTC=${RUST_ROOT}/build/x86_64-apple-darwin/stage1/bin/rustc cargo build --target=x86_64-unknown-fuchsia

The command above will generate the binary in target/x86_64-unknown-fuchsia/debug/xi-core.


First configure your build:

fset x86-64 --modules default,rust

Generate and build:

fgen -m=default,rust
${FUCHSIA_DIR}/scripts/ --tree=//apps/xi/*

Assuming you have a working Acer setup and are running fboot in a different terminal session, you can reboot the Acer with the new build using:


Optional: In another terminal you can tail the logs


You can run the mx_toy example from your host with:

netruncmd : "example_mx_toy"

You won't see any output, if you run example_mx_toy on the device you should see some log output.

To run Xi from your host machine:

netruncmd : "@ bootstrap device_runner --user-shell=dev_user_shell --user-shell-args=--root-module=xi_app"

Android & Flutter

To run Xi on Android (via the Flutter framework) you will first need to build the xi-core binary for the Android target:

git clone ${FUCHSIA_DIR}/apps/xi-editor
cd ${FUCHSIA_DIR}/apps/xi-editor/rust
brew install android-ndk
export NDK_HOME="$(brew --prefix)/opt/android-ndk"
${NDK_HOME}/build/tools/ \
  --platform=android-18 --toolchain=arm-linux-androideabi-clang3.6 \

Add a config for the android target:

mkdir .cargo
cat - <<EOF >.cargo/config
target = "arm-linux-androideabi"

linker = "${FUCHSIA_DIR}/apps/xi-editor/rust/android-18-toolchain/bin/clang"

Finally, build the binary and push it to a connected Android device:

cargo build
adb push target/arm-linux-androideabi/debug/xi-core data/local/tmp/

Run the Flutter app:

cd ${FUCHSIA_DIR}/apps/xi/xi_flutter
fgen -m=default,rust
${FUCHSIA_DIR}/scripts/ --tree=//apps/xi/*
${FUCHSIA_DIR}/lib/flutter/bin/flutter run