The iPhone app
bnw_node::embedded::spawn(data_dir, identity, config) runs a node on its own thread inside another process and returns a NodeHandle:
request("node-status", json!({}))takes the same operations and JSON as the web gateway;events()gives the live events the web client streams;shutdown()stops the node.
The host supplies the device key, for example from the iOS Keychain, so the node never reads a key file. If the device creates the account, the host also supplies where the account’s root key lives (NodeConfig::account_keys, a pairing::AccountKeyStore); the node asks it for the key only to sign.
The mobile app runs the node with role: NodeRole::Companion and local_sockets: false. A companion is a real device of its account: it syncs, messages, pairs, and decides approvals with its own key. It runs no agents, executes no provider requests, answers no searches, and refuses provider and agent-hosting operations. Those stay on a computer, and the phone manages them.
bnw-node builds for aarch64-apple-ios and aarch64-apple-ios-sim. Android needs the NDK and a rustls TLS backend first.
The iPhone app
Section titled “The iPhone app”apps/bnw-ios is the consumer app, BNW for iPhone on the App Store: native SwiftUI after the design in design/. Its Rust side is crates/bnw-ffi, which exposes the embedded companion node to Swift through UniFFI with four calls:
start(dataDir, secret, relays, accountKeys): with no relays, BNW’s public relays, the same default as desktop nodes.accountKeysis the app’sAccountKeyStore, which keeps the account’s root key if the phone creates the account;request(op, json), with the web gateway’s operations and JSON;subscribe(listener)for live events;stop(), andshutdown(), which waits until the node has closed its data directory.
Signing up and deleting. Creating, joining, or restoring an account first asks the person to agree to the Terms of Use and Privacy Policy, which allow no objectionable content or abusive users. You → Delete account erases the account from the phone: this phone leaves the account, the node shuts down, and its data, the device key, the account key and its iCloud Keychain backup, and the app’s settings are deleted, before the app starts over. On the phone holding the account key, it first removes every other device, which closes the account. Messages already delivered stay with their recipients.
The device key lives in the iOS Keychain (this device only, after first unlock), and the app loads nothing remote. An account root key created on the phone is a separate Keychain item, this device only and readable only after Face ID or the passcode, with an optional iCloud Keychain copy the user chooses at creation. Keychain items outlive the app but its data doesn’t, so a reinstalled app (an empty data directory) gets a new device key and joins as a new device; reusing the old key with an empty store would sign records older than the ones the network already has. An account key still in the Keychain is offered as Restore my account, never used to create the account again, which would fork it.
Ready for distribution:
- The app’s version is the workspace version from
Cargo.toml, and its build number is the commit count, both stamped at build time. PrivacyInfo.xcprivacydeclares no tracking and no collected data. It also declares the reasons for the system APIs used:UserDefaultsfor read markers, file timestamps and disk space for the store and SQLite in the app’s container.- Export compliance is answered in App Store Connect: the app uses standard end-to-end encryption.
ITSAppUsesNonExemptEncryptionis added toproject.ymltogether with theITSEncryptionExportComplianceCodethat answer produces. Declaring it without the code fails upload validation. - The local-network usage text explains direct connections to the user’s other devices on the same Wi-Fi.
- Simulator builds need a signature, even ad hoc (
CODE_SIGN_IDENTITY=-), for the Keychain to hold the device key.
TestFlight uploads. Build the release core, then archive and upload with the Apple account signed into Xcode. Automatic signing creates the distribution certificate and profile:
scripts/build-ios-core.shcd apps/bnw-ios && xcodegen generatexcodebuild archive -project BNW.xcodeproj -scheme BNW -configuration Release \ -destination 'generic/platform=iOS' -archivePath build/BNW.xcarchive -allowProvisioningUpdatesxcodebuild -exportArchive -archivePath build/BNW.xcarchive -exportPath build/export \ -exportOptionsPlist ExportOptions.plist -allowProvisioningUpdatesExportOptions.plist uploads to App Store Connect (method app-store-connect, destination upload). Build numbers are commit counts, so commit before uploading a new build.
scripts/build-ios-core.sh # Rust core → apps/bnw-ios/Core (XCFramework + Swift bindings)cd apps/bnw-ios && xcodegen generate # Xcode project from project.ymlopen BNW.xcodeproj # run on a simulator or a connected iPhoneAdding the phone to your account:
- On the computer, run
bnw account pair, or use the web client’s Account → Add a device. - Scan its QR code in the app, or with the iPhone’s Camera. Tapping a
bnw:pair/…link opens the app with it filled in. - Tap Join.
- The computer lists the phone as asking to join, with its matching code. On the computer that holds the account key, check the code matches the phone’s and press Confirm in the web client’s Account card.
The Confirm button signs with the account key in the node’s data directory. Only the node itself can use it, never a hosted agent acting through it, and only for a device that asked to join this account. bnw account authorize-device <phone> does the same from the command line, and can also authorize a device before it asks.
Once it’s a member, the phone:
-
Home: your node’s state, what needs you, your agents, and live activity.
-
Network: how it is reachable, its relay, and who it is connected to.
-
Messages:
- direct messages and channels;
- a new-message menu: message a contact, create a channel, or open a contact or channel link;
- Join buttons on channel links;
@suggestions in the message box, with agents first. A suggestion inserts the exact name an agent answers to, or its ID when two share a name.
-
Approvals: the full draft or tool input, decided after Face ID and signed with the phone’s own key.
-
Notifications and background:
- New direct messages and approval requests addressed to you or your account become notifications, shown as banners while the app is open too (except for the conversation on screen). Tapping one opens the conversation or Approvals.
- You says when notifications are switched off for BNW, with a link to Settings.
- The app badge counts pending approvals.
- Leaving the app keeps the node syncing for 3 to 10 seconds, until it goes quiet. iOS background refresh wakes it now and then; it reconnects, catches up, and stops once quiet, within 25 seconds.
- Battery. Off screen, the phone’s node checks for events and receipts every 10 seconds instead of every second (
host-foregroundtells it), and it syncs every 30 seconds. The app never runs continuously in the background. - Push. While the app is suspended or closed, a reply from someone this account wrote to, from this phone or another of its devices (a direct message, or a channel post that answers or mentions it), or an approval request for its account, arrives as a generic “New message” or “Approval needed” push. The app wakes, fetches it, and replaces the push with its usual notification. See Push notifications.
- Tapping a push opens Approvals, or the conversation or channel of the message it announced. The push names nothing, so the app opens where the next message from someone else arrives within 8 seconds, or else the conversation with the newest message of the last hour. iOS doesn’t wake an app the user swiped away, so for such an app the generic push stays until tapped.
-
Links:
bnw:pair,bnw:contact,bnw:channelandbnw:capabilitylinks, from the Camera or tapped anywhere, open the app to join, add, pair, or show the capability. -
Request forms: a tool whose input is a flat object of simple fields gets a form, with a Form/JSON switch over the same request. Send waits until required fields are filled.
-
Sharing: Share on a capability or an agent sends its link to a channel or a contact, or to the system share sheet.
-
Offline banner: shown when no peer or relay is reachable.
-
Agents:
- per-channel permission modes (Off, With approval, On its own) and tool permissions, with tools shown by name;
- Add tools: search the catalog by words and category and grant several tools at once;
- the signed audit trail.
The phone signs the grants it adds and can revoke the ones it signed; grants made on another device are changed there.
-
Services:
- federated search, with retrieve-and-verify for other people’s results;
- the catalog by kind, filtered by words and categories;
- each service’s declared data handling, trust, and follow;
- using a service: the request is encrypted for its provider, the answer is decrypted, and provenance is checked.
-
You:
- contacts;
- your contact link;
- devices, with sending history to one and adding another;
- recovery and wallet (informational for now);
- data rules (the routing policy);
- storage;
- settings sync.
Hosted agents and your account: an account operates hosted agents, so every device of the account manages them and decides their approvals. New hosted agents link to the host’s account. Existing ones are linked to the account, with the agent’s own key, once their host belongs to one.
