The iOS app
apple/ios/ is a SwiftUI shell around the same SPA the desktop app embeds
(plan 42). The Rust core (crates/ledgeline-ffi, mobile feature) runs
in-process, linked as a static library. The app’s web view loads
ledgeline://localhost/, and a URL scheme handler passes every request to the
core’s router. There’s no socket and no port. The contract between Swift and
Rust is in crates/ledgeline-ffi/README.md, and the bridge between the page
and Swift is in plan 42.
The Swift is split so the invoicer’s app (plan 51) can share it:
apple/ios/Shared/is the shell: the scheme handler, the native bridge, the saved-books list and its App Group storage, the session, the list and ledger screens, Face ID, pinch, share sheet and pickers. It never namesLedgelineApp. It calls anEngine(Shared/Model/Engine.swift).apple/ios/Ledgeline/is Ledgeline’s own: theAppentry,LedgelineShell.swift(theLedgelineAppadapter, the sample and theShellConfig: scheme, start page, names, icons) andLedgelineSections.swift(the section ids the bridge contract test reads).apple/ios/Invoicer/is the invoicer’s: itsAppentry,InvoicerShell.swift(theInvoicerAppadapter, its sample and itsShellConfig) and the native host.
Each app lists a sample on its first launch and rewrites it on every open, so
it is always fresh and dated to this month. Both write the same sample books
(write_sample_books(), ledgeline_core::sample_books), each into its own
Documents/Sample folder: Ledgeline’s sample journal plus a small side
business, with a company note, four customers (one with a purchase order, one
on the Modern template), a catalog, a payment snippet, eight invoices (paid,
part paid against a deposit, voided and reissued, overdue with deferred
revenue, not yet due, a draft), unbilled time and a contractor’s bill. The
files are checked in under crates/ledgeline-core/src/sample_books/, generated
by the invoicer’s own code (just sample-books, ledgeline_invoicer::sample);
Rust moves every date by whole months into the device’s current month. The
apps don’t share one folder (each sample is in its app’s own container), so
Ledgeline’s Invoices page still offers no Open Ledgeline Invoicer on its
sample.
Both apps are in the App Group group.com.zmre.ledgeline
(Ledgeline/Ledgeline.entitlements). The saved list is stored in the group’s
defaults and the config folder (ui-prefs.toml) in the group container, so
both apps share them. Bookmarks are per app, so an entry this app has no grant
for shows “Allow access”. On its first launch after the update, Ledgeline
copies its old list and config folder into the group once and leaves the old
copies in place. Without the group (a build signed without it), the app falls
back to its own list and folder, and the log says so.
You need macOS with Xcode 26, the Nix dev shell (it includes the iOS Rust
targets), and bun.
Commands
| Command | What it does |
|---|---|
just ios-build | Builds the SPA, the release staticlibs, the Swift bindings, the xcframework and the simulator app. |
just ios-run | Does the same, then boots the “iPhone 17” simulator, installs the app and launches it. |
just ios-test | Runs the Swift unit tests on the simulator. |
just ios-device | Builds a signed Release app for a device. |
just ios-install | Installs the last device build on $LEDGELINE_IOS_DEVICE and launches it. |
Each recipe calls apple/ios/build.sh [--app ledgeline|invoicer] <mode>, and
the modes are rust, build, run, device, install and test.
--app defaults to ledgeline; --app invoicer builds the invoicer’s app
(invoicer-ffi, apple/ios/Generated/Invoicer/). The script’s header
lists its environment variables. These are the ones you’ll use most:
LEDGELINE_IOS_DEVICE=<udid>: the phone to build for and install on. Get the UDID fromxcrun devicectl list devices. A development profile needs a registered device, and naming the phone lets Xcode register it.LEDGELINE_SIM_DEVICE: a simulator other than “iPhone 17”.LEDGELINE_IOS_SKIP_SPA=1: reusesweb/buildas it is, which saves the SPA build when only Swift changed.
How the build fits together
bun run buildinweb/.crates/ledgeline-server/build.rsmirrorsweb/buildinto the crate’sspa/.scripts/ios-check.sh buildcross-compilesledgeline-ffiforaarch64-apple-iosandaarch64-apple-ios-sim. It always uses the release profile, whatever the Swift configuration, because rust-embed bakes the SPA into release builds only. A debug staticlib would readspa/from disk at run time, and that path doesn’t exist on a phone. The script’s shims send only the target-side C compiles to Xcode’s SDK.- The crate’s
uniffi-bindgenbin (featurebindgen) writes the Swift bindings toapple/ios/Generated/, which is checked in. It replaces files only when they change. xcodebuild -create-xcframeworkproducesLedgelineFFI.xcframework.- XcodeGen produces
Ledgeline.xcodeprojfromproject.yml. It comes fromnix run nixpkgs#xcodegenunless one is onPATH. xcodebuildruns with the Nix shell scrubbed from its environment (env -i,DEVELOPER_DIRset to Xcode’s).
The project file, the xcframework and target/ios-* are build products and
aren’t committed.
Gotchas
- The Nix shell sets
DEVELOPER_DIRto a Nix macOS SDK. Never export Xcode’sDEVELOPER_DIRorSDKROOTglobally, because that breaks Nix’s host linker. Runxcrunandxcodebuildfor iOS withDEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer. - A global
*.sw*ignore pattern would hide the Swift sources. The repo’s.gitignorere-includesapple/ios/**/*.swift. simctlcan’t tap. In Debug builds,SIMCTL_CHILD_LEDGELINE_OPEN_SAMPLE=1 xcrun simctl launch booted com.zmre.ledgeline.iosopens the sample ledger at launch, which helps with screenshots (com.zmre.ledgeline.invoicer.iosopens the invoicer’s sample books). Two more Debug-only variables go with it:SIMCTL_CHILD_LEDGELINE_START_PATH="/reports?tab=bs"opens that route first, andSIMCTL_CHILD_LEDGELINE_DEBUG_JS='…'runs a script about 1.5 s after the first load, for example to click a button or open the problems drawer. The script is a function body, soreturnhands a value back to the log. Take the screenshot withxcrun simctl io booted screenshot out.png.- The web view runs under the native bar.
env(safe-area-inset-top)is 116 px on an iPhone 17 andinnerHeightis the whole screen. Anythingposition: fixednear the top has to use--ll-top-inset(app.css). - App logs go to stderr under
simctl launch --console-ptyand to the unified log (subsystemcom.zmre.ledgeline.ios). Logging never writes journal contents. At launch the log says whether the App Group container resolved (app group: …) and what the migration copied. xcrun simctl openurl booted "ledgeline-app://open?books=<id>"tests the invoicer’s Open in Ledgeline link, after a tap on the system’s “Open in Ledgeline?” prompt. Without a tap, in Debug builds:SIMCTL_CHILD_LEDGELINE_OPEN_URL="ledgeline-app://open?books=<id>". The id is the saved entry’s, from the group’s defaults.- The other way, Ledgeline’s Invoices page links to
ledgeline-invoicer-app://open?books=<id>(the Invoicer’s URL type). Ledgeline hands the link to Rust (LedgelineApp.setInvoicerLink) only for a folder entry, and only oncecanOpenURLsays the Invoicer is installed; the page follows it and the web view opens it outside the app. Test it the same way, with the Invoicer installed:xcrun simctl openurl booted "ledgeline-invoicer-app://open?books=<id>". - Opening a ledger asks for Face ID or the passcode (per-ledger, on by
default). A simulator with a passcode shows the passcode sheet. To use
Face ID instead, enroll it with
xcrun simctl spawn booted notifyutil -s com.apple.BiometricKit.enrollmentChanged 1thennotifyutil -p com.apple.BiometricKit.enrollmentChanged, and answer each prompt withnotifyutil -p com.apple.BiometricKit_Sim.pearl.match(orpearl.nomatch). With neither, the ledger opens and the log says so. simctlcan’t swipe or pinch either. ALEDGELINE_DEBUG_JSscript can dispatchPointerEvents withpointerType: "touch"on a journal card to drive its swipes and long press. A pinch sends the page’sledgeline:zoomevent, which a script can dispatch directly.