1. Open your first window
Choose the computer you’ll build on. Your choice applies throughout these six lessons.
Build a Session counter in six lessons using AppKit on macOS, WinUI on Windows, or GTK on Linux. Use the same host platform throughout. Prerequisites: basic Rust, a terminal, and a text editor. A target combines an OS and UI toolkit; a Piece describes UI controls or containers.
1. Prepare your computer
Install Git and stable Rust through rustup, then install the platform tools:
macOS
Use an Apple silicon Mac with full Xcode 27 or newer. Open Xcode once to finish installation. In Terminal, use Bash or Zsh.
Windows
Use Windows with Visual Studio C++ Build Tools, the Windows SDK, the MSVC Rust toolchain, and Windows App Runtime 2.5.1 or newer. Use PowerShell 7 in a Developer PowerShell terminal so the C++ tools are on PATH.
Linux
These instructions use Ubuntu 24.04 or newer with GTK 4.10+, libadwaita 1.5+, librsvg 2.52+, their development packages, and pkg-config. Use Bash in a desktop session.
See system requirements. Select full Xcode on macOS; use the MSVC Rust toolchain on Windows. The Day installation does not install SDKs.
2. Install Day
macOS
cargo install day-cli --locked
Windows
cargo install day-cli --locked
Linux
cargo install day-cli --locked
This compiles the latest published CLI from crates.io into Cargo’s executable directory.
If day is not found, open a new terminal or check PATH.
This desktop debug app requires neither mobile SDKs nor a developer signing account.
Check the CLI and toolkit installation:
macOS
day --version
day doctor --toolkit appkit
Windows
day --version
day doctor --toolkit winui
Linux
day --version
day doctor --toolkit gtk
3. Create the project
Run in your projects directory. Use an unused name if first-app exists.
macOS
mkdir -p first-app/src first-app/resource/locales/en
cd first-app
Windows
New-Item -ItemType Directory -Path first-app/src, first-app/resource/locales/en
Set-Location first-app
Linux
mkdir -p first-app/src first-app/resource/locales/en
cd first-app
All following paths are relative to this app directory. Create these files:
Write Cargo.toml:
[package]
name = "first-app"
version = "0.1.0"
edition = "2024"
[workspace]
[lib]
name = "dayapp"
The empty [workspace] isolates the app from enclosing Cargo workspaces. [lib] name = "dayapp"
names the library used by main.rs and native hosts. Create source files before adding dependencies.
macOS
Write Day.toml:
schema = 1
[app]
id = "dev.daybrite.tutorial.session-counter"
title = "Session counter"
build = 1
targets = ["macos-appkit"]
[window]
width = 640
height = 480
min_width = 400
min_height = 320
Windows
Write Day.toml:
schema = 1
[app]
id = "dev.daybrite.tutorial.session-counter"
title = "Session counter"
build = 1
targets = ["windows-winui"]
[window]
width = 640
height = 480
min_width = 400
min_height = 320
Linux
Write Day.toml:
schema = 1
[app]
id = "dev.daybrite.tutorial.session-counter"
title = "Session counter"
build = 1
targets = ["linux-gtk"]
[window]
width = 640
height = 480
min_width = 400
min_height = 320
Use a unique app ID for a product. Window dimensions are in points. The manifest title is packaging metadata; the visible window title comes from the Fluent catalog.
Write build.rs:
fn main() {
day_build::prebuild_project().expect("day-build: prebuild");
}
Write resource/locales/en/app.ftl:
app_title = Session counter
welcome = Count the sessions you finish today.
The build script generates typed accessors for Fluent messages.
Write src/lib.rs:
use day::prelude::*;
day::resources!();
day::day_start!(options: res::window_options(), root);
pub fn root() -> impl Piece {
label(res::str::welcome())
.padding(Space::L)
.id(id!(welcome_label))
}
Write src/main.rs:
fn main() {
day::launch(dayapp::res::window_options(), dayapp::root);
}
day::resources!() exposes res. res::window_options() installs the catalog and sets the
localized title and manifest geometry. root() defines the content; Space::L is a spacing token.
day_start! supplies the native-host entry point; main.rs supplies the Rust desktop entry point.
welcome_label identifies the label for automation independently of its translated text.
Add the dependencies:
macOS
cargo add 'day-app@0.*' --rename day
cargo add --build 'day-build@0.*'
Windows
cargo add 'day-app@0.*' --rename day
cargo add --build 'day-build@0.*'
Linux
cargo add 'day-app@0.*' --rename day
cargo add --build 'day-build@0.*'
cargo add records dependency requirements in Cargo.toml; Cargo locks exact versions in
Cargo.lock. Keep the lockfile. The day-app package exports the day library;
--rename day sets the dependency key. day-build is used by build.rs.
Append to Cargo.toml:
[features]
default = ["mock"]
mock = ["day/mock"]
appkit = ["day/appkit"]
gtk = ["day/gtk"]
winui = ["day/winui"]
The default mock feature supports editor checks. day build selects the target’s toolkit feature.
4. Prepare the native host
On macOS, generate the Swift runner and host configuration:
macOS
day project add-target macos-appkit
Keep the files under platform/macos/. Builds generate the Xcode project.
Windows and Linux use main.rs and skip this command.
5. Build and open the window
Run from first-app:
macOS
day build -t macos-appkit
Windows
day build -t windows-winui
Linux
day build -t linux-gtk
macOS
day launch -t macos-appkit
Windows
day launch -t windows-winui
Linux
day launch -t linux-gtk
Expect a successful build and a window titled Session counter displaying Count the sessions you finish today. Debug builds may append build information to the title.
macOS
Quit with Command-Q before continuing.
Windows
Close the app window before continuing.
Linux
Close the app window before continuing.
day launch also builds; use it after subsequent edits. A missing-icon notice is expected
because this app has no custom launcher icon.
Troubleshooting
| Symptom | Check and recovery |
|---|---|
day: command not found | Add Cargo’s executable directory (~/.cargo/bin by default) to PATH; open a new terminal. |
| Doctor rejects Xcode | Select full Xcode 27 or newer with DEVELOPER_DIR; run day doctor --toolkit appkit. Command Line Tools alone are insufficient. |
Cargo cannot find day | Check day-app, day-build, and connectivity to crates.io. |
Missing res::str accessor | Check the catalog path and key; rebuild. Do not edit generated Rust. |
| Launch cannot find the project | Run from the directory containing Day.toml. |
Editor support
The VS Code extension provides project and target commands. See agent instructions for coding conventions.
Next step
Continue to 2. Handle a button click.