How Foglio is built, and why that makes it small and fast

Most modern desktop apps ship a copy of a web browser, a Java runtime or a big cross-platform framework. Foglio ships none of them. It is a native Mac app in Swift and AppKit, with the spreadsheet engine written in Rust and linked straight into the app.

This page explains the architecture twice: first in plain words, then in enough detail for a developer to find their way around the source code.

The short version

Think of Foglio as two parts. The part you see (windows, menus, the grid of cells) is written with Apple's own tools, so it looks and behaves like every other Mac app. The part that does the maths (reading files, understanding formulas, recalculating) is a separate engine written in Rust, a language that produces very fast, compact programs.

The two parts talk through a small, plain interface. Nothing sits in between: no hidden browser, no virtual machine, no runtime to download. That is why the whole app is a 7.5 MB download, launches in 0.24 s and needs about 58 MB of memory with an empty sheet.

The Mac app: Swift and AppKit

The interface is written in Swift on AppKit, the framework behind Finder and most of the Mac's own apps. Documents are real macOS documents, so Open Recent, Save As, Revert, Duplicate, window tabs, full screen, dark mode, printing and Export PDF work the way you expect.

The sheet itself is a custom NSView grid, not a table control. It asks the engine only for the cells that are visible, in batches ready to draw, which keeps scrolling smooth on sheets with hundreds of thousands of rows. Charts, pictures and the formula bar are drawn by the app too.

Foglio also contains its own player for EMF and WMF metafiles, the vector picture format of older Office documents (clip art, MathType equations, pasted Visio diagrams). Pictures that other Mac apps show as blank boxes are drawn properly and saved back unchanged.

The engine: Rust and a patched IronCalc

Formulas are parsed and evaluated by IronCalc, an open-source spreadsheet engine in Rust. Foglio uses a patched fork of IronCalc 0.9.1 with every change marked and documented in the repository.

The fork adds incremental recalculation: when you edit a cell, only the formulas that depend on it are recalculated, instead of the whole workbook. On a workbook with 100,000 rows and 300,000 formulas, an edit takes 16 ms; a full recalculation takes 64 ms.

It also adds indexed lookups. The first VLOOKUP, MATCH or XLOOKUP into a range reads it once and builds a hash index; later lookups are a single probe. 1,000 exact VLOOKUPs over 10,000 rows went from 1,703 ms in upstream IronCalc to 1.3 ms in Foglio's fork. The fork also fixes a dozen functions so that 191 of the 195 functions in Foglio's compatibility audit match Excel on every test case.

  • Older .xls, binary .xlsb and LibreOffice .ods files are read with calamine, a fast Rust reader.
  • CSV and TSV files go through a Rust importer that detects the text encoding, the delimiter and the decimal separator.
  • Formulas typed in Italian, German, Spanish or French are translated to Excel's standard English form before they are stored.

The bridge: a plain C interface

The Rust engine is compiled as a static library and exposes a small C interface (foglio_core.h): open and save a file, edit a cell, return a batch of visible cells. Swift calls it directly through a bridging header. There are no generated bindings, no frameworks and no inter-process messages, so a call into the engine costs about as much as a normal function call.

No Xcode project

Foglio is built with two commands: cargo builds the Rust library and swiftc compiles the app and links it. A shell script produces a universal app for Apple silicon and Intel and wraps it in a disk image with Apple's own hdiutil. You need the Xcode Command Line Tools and Rust; full Xcode is not required.

Fewer layers mean fewer things to go wrong, faster builds, and a project that anyone can read from top to bottom.

Tested with real keyboard and mouse events

Foglio has 69 UI tests that drive the real app with real keyboard and mouse events: typing formulas, filling ranges, sorting, undoing, saving and reopening files. The file importers and the formula engine have their own Rust test suites, and a special mode re-checks every incremental recalculation against a full one.

Why this makes Foglio small and fast

An Electron app carries a full copy of the Chromium browser, typically well over 100 MB before it does anything. A Java or cross-platform suite carries its runtime and its own UI toolkit. Foglio carries only its own code and uses the frameworks already on every Mac.

The Rust core is compiled with full link-time optimization and stripped of debug symbols. The result is a universal app of about 19 MB on disk, 7.5 MB as a compressed download, that idles at 0 % CPU.

Frequently asked questions

Is Foglio an Electron or web app?

No. It is a native AppKit app written in Swift. There is no browser engine inside it.

Does it run natively on Apple silicon?

Yes. Foglio is a universal app with native code for both Apple silicon (arm64) and Intel (x86_64).

Can I build Foglio myself?

Yes. Install the Xcode Command Line Tools and Rust, then run scripts/build.sh. The README has the exact commands.

Are the IronCalc changes contributed upstream?

The fork is open source under the same licenses as IronCalc, and every change is marked with a Foglio fork: comment and described in third_party/README.md, so it can be reviewed and reused.

Try it on your own spreadsheets

It is a 7.5 MB download and it costs nothing. Foglio 1.0 is a first release, so keep backups of important files while you try it.

Download for MacView source on GitHub

Free · macOS 14+ · Apple silicon & Intel · 7.5 MB