rastrillo / native Public

Clone
git clone https://amadan.net/rastrillo/native

Plain git — no account needed to clone.

Download

Download this file

1---
2name: rastrillo-native
3description: Build native companions for Rastrillo apps using shared Swift components, an Apple app scaffold and optional Go Mobile bindings.
4---
5
6# Rastrillo Native
7
8Optional sibling of Rastrillo web. Source and review:
9`https://amadan.net/rastrillo/native`. Swift product/module:
10`RastrilloNative`, iOS 17+ and macOS 14+. Pin the package to a reviewed
11revision and read this file from that checkout. Core Rastrillo does not
12import native tooling.
13
14Start from `examples/companion/project.yml` and `Sources/Companion.swift`.
15Copy into the app; replace the local package path with the repository URL
16and revision, set app-owned bundle IDs, run `xcodegen generate`. The example
17checks `/api/version` only; it supplies no authenticated session. The app
18owns linking, navigation, storage, signing and release policy.
19
20## Prefer native UI
21
22Aim for a fully native interface wherever practical. Meeting the platform's
23expectations can substantially improve daily use: navigation, selection,
24menus, context menus/right-click, keyboard shortcuts, accessibility, links,
25windows and system sharing should behave as people already expect. Treat
26those behaviours as part of the feature, not final polish. Share logic and
27contracts freely; let each platform own how the feature is presented.
28
29For a complex app, a native navigation layer around selected webview screens
30can avoid duplicating a large working surface. Use that as a deliberate
31boundary: keep app navigation, menus, contextual actions and link routing
32native, and expose typed actions from the embedded screen. Route internal
33links to native destinations and ordinary external links through the
34platform's normal browser behaviour. Do not intercept text editing or
35replace useful web behaviour with a less capable native imitation.
36
37If both clients would otherwise duplicate navigation and action definitions,
38consider a shared app manifest compiled into separate web and native
39presentations. Share destination IDs, available commands, capabilities and
40link intent; each renderer chooses platform-appropriate controls. A command
41may appear in a web toolbar, a Mac menu/context menu, or an iPhone action
42menu. Avoid encoding DOM trees, pixel layout or one platform's navigation
43model as the common schema. See [docs/app-architecture.md](docs/app-architecture.md).
44This is architectural guidance, not an existing dual-target generator;
45Rastrillo's current resource manifests generate web CRUD only.
46
47## Shared components
48
49`@MainActor CoalescedRunner.run` serializes one refresh operation. A burst
50during a pass queues one trailing pass; callers await its completion.
51Trailing passes reuse the first caller's closure. Keep one runner per
52operation/account, handle errors inside the closure, and never recursively
53call it from the work it runs. Cancelling a waiter does not cancel shared
54work. Existing consumers can keep their public API with
55`public typealias CoalescedRunner = RastrilloNative.CoalescedRunner`.
56
57Native platform integrations belong in platform adapters. Share API and
58crypto contracts with the web app; replay the same golden vectors before
59claiming compatible bytes. Reuse Rastrillo crypto/keyring where compatible;
60do not migrate existing envelopes just to use the package. Native secure
61storage, browser key storage, Web Push and APNs/FCM have different lifecycle
62contracts. Never treat aviso as native push transport.
63
64For an app with reusable Go logic, read [docs/go-mobile.md](docs/go-mobile.md).
65Go Mobile is optional; the shipped Swift component does not require it.
66Android bindings and UI are not supplied by this first package.
67
68Run `make ci`: Swift tests plus unsigned iOS simulator and macOS builds.
69Consumer adoption also runs that app's core tests and builds; a package
70test alone cannot detect a missing Xcode dependency. Keep release/device
71checks distinct from compile checks.
72