Skip to content

WritingwatchOS architecture when the phone is not there

Writing

9 min read

watchOS architecture when the phone is not there

Structuring a watchOS app around a phone you cannot depend on, with the connectivity budget and the cases where the watch works alone.

Most watch apps start as a remote control for the iPhone app. The watch asks, the phone answers, the watch renders. It works at the desk where it was built, with both devices on the same Wi-Fi and the phone unlocked next to the keyboard.

Then someone goes for a run and leaves the phone at home, or the phone is in a bag on the other side of the room with Bluetooth asleep. The watch app shows a spinner, then a stale value, then nothing. The reviews say "the watch app doesn't work", and from the user's point of view that is accurate.

The fix is to design the watch as a client that sometimes has a phone nearby, instead of a screen that sometimes loses its phone.

1. Decide what the watch can do alone

Before any code, write down which features must work with the phone out of range. For most apps the list is short, and that is fine:

  • show the last known state, with its age
  • record something the user did (a set, a log entry, a check-off) and keep it until it can be delivered
  • one or two read paths that justify their own network access

Everything else can say "open on iPhone" honestly. What hurts is the feature that depends on the phone and pretends otherwise by spinning forever.

This list also decides your project setup. If the watch app should install and run without the iPhone app, enable "Supports Running Without iOS App Installation" in the watch target. That commits you to authentication, networking and storage on the watch itself. Turning it on later is the expensive direction, because every assumption about a nearby phone has to be found and removed.

2. Local state is the source of truth on the watch

The watch app should render from its own store, never from a reply it is waiting for. SwiftData and Core Data both run on watchOS. For small apps a Codable file in the app container is enough, and easier to reason about.

The shape that holds up looks like this:

@Observable
final class WatchStore {
    private(set) var snapshot: Snapshot
    private(set) var pending: [PendingAction] = []
 
    func apply(_ incoming: Snapshot) {
        guard incoming.version > snapshot.version else { return }
        snapshot = incoming
        persist()
    }
 
    func record(_ action: PendingAction) {
        pending.append(action)
        persist()
        outbox.flush(pending)
    }
}

Two details carry most of the weight. Every snapshot has a version, so an older update that arrives late cannot overwrite a newer one. User actions go into a persisted outbox before anything tries to send them, so a check-off made in a tunnel survives the app being suspended.

Show the age of the data. "Updated 3 h ago" next to a number is more useful than the number alone, and it is the cheapest way to stop users from trusting a value that went stale while the phone was at home.

3. Pick the WatchConnectivity call by delivery guarantee

WCSession offers four transfer methods, and what separates them is the delivery guarantee. Choosing the wrong one is where most of the "works on my desk" bugs come from.

MethodDeliveryUse it for
sendMessageOnly while the counterpart is reachable; fails otherwiseLive interaction while both apps are active
updateApplicationContextLatest value only; each call replaces the previous oneCurrent state: settings, the latest snapshot
transferUserInfoQueued in order, delivered eventuallyEvents that must all arrive: logged entries, actions
transferFileQueued, delivered eventuallyLarger payloads, exported data

sendMessage is the one teams reach for first, because it feels like a function call with a reply handler. It is also the only one that gives up when isReachable is false, which on a watch is most of the time. Treat it as a fast path that is allowed to fail, with a fallback to one of the queued methods.

func send(_ action: PendingAction) {
    let payload = action.dictionary
    guard session.activationState == .activated else { return }
 
    if session.isReachable {
        session.sendMessage(payload, replyHandler: nil) { [weak self] _ in
            self?.session.transferUserInfo(payload)
        }
    } else {
        session.transferUserInfo(payload)
    }
}

The fast-path-with-fallback pattern means the receiver has to deduplicate, because a message can arrive through both paths. Give each action an id and ignore ids you have already applied. That is a few lines on the phone side and saves a class of double-logged entries.

updateApplicationContext fits state the phone pushes to the watch, because the watch only cares about the newest version. Sending a sequence of events through it loses all but the last one, quietly.

4. Give the watch its own network path

The watch can use URLSession directly, over the phone's connection when it is nearby, or over Wi-Fi or cellular when it is not. For an app that must work alone, this is the main data path, and WatchConnectivity becomes the optimisation for when the phone happens to be around.

The constraints are different from the phone:

  • Requests are slower and more likely to be cut off when the app leaves the screen. Keep responses small and purpose-built for the watch instead of reusing the phone's full endpoint.
  • The app is suspended quickly after the wrist drops. A request started in the foreground may never complete. Use a background URLSession for anything that has to finish, and handle the result in the background task the system hands you later.
  • There is no guarantee of a network at all. The outbox from section 2 is what makes that acceptable.

A dedicated watch endpoint that returns exactly what one screen shows, in a few hundred bytes, is worth more than any client-side optimisation. It also gives the backend a place to see watch traffic separately when something goes wrong.

5. Authentication cannot borrow the phone's session

The keychain on the watch is the watch's keychain. Tokens stored on the phone are not there, and a watch app that works alone needs its own way to sign in.

The workable options, in the order I would try them:

  • Sign in with Apple, which works on watchOS and needs no typing.
  • Hand the token over from the phone through transferUserInfo when the phone app is installed, then store it in the watch keychain. Treat this as a convenience, because the watch-only install never gets it.
  • A short code or QR flow where the user confirms on another device.

Whatever you choose, plan for expiry. A watch app may sit unopened for weeks. The first launch after that has an expired access token and possibly no phone nearby, so the refresh path has to run on the watch with its own network access. If it cannot, show a clear signed-out state instead of failed requests.

6. Work with the runtime budget

A watch app runs in short visits. The user raises the wrist, reads, maybe taps once, and lowers it. Most visits are measured in seconds, and the system suspends the app soon after.

That changes what "loading" can mean:

  • Render immediately from the local store. Fetch in parallel, and update the screen if the result arrives while it is still visible.
  • Schedule background app refresh for data the user expects to be current when they look. The budget is small and the system decides when it runs, so request it for the moment the data matters (before a commute, after a scheduled event) instead of on a fixed short interval.
  • Use the background tasks the system delivers, such as URL session and WatchConnectivity tasks, to apply incoming data and persist it. Mark each task complete promptly; holding them is how an app loses its budget.

Workouts and a few other session types get extended runtime through HKWorkoutSession or WKExtendedRuntimeSession. If your app does not fit those categories, design for the short visit instead of searching for ways around it.

Complications have their own update budget and failure modes, and they are a topic of their own.

7. Test with the phone gone

Every development setup hides the problem, because the phone is always nearby and unlocked. Make the missing phone part of the test plan:

  • Turn on airplane mode on the iPhone, then use the watch app for a full session. Confirm that every screen renders, every action lands in the outbox, and nothing spins without end.
  • Reconnect and check that the outbox drains exactly once on the phone side.
  • Install the watch app without the iPhone app, if you support that, and go through sign-in from scratch.
  • Leave the watch app untouched for a few days, then open it away from the phone. This is the expired-token path, and nobody hits it in a normal test pass.

Log the connectivity state with each transfer (isReachable, which method was used, the outbox depth). When a user reports that their entries "disappeared", that log is the difference between a fix and a guess.

8. Where to draw the line

A watch app that mirrors every phone feature through sendMessage looks complete in a demo and fails on the first run without the phone. A watch app with three features that work anywhere, from local state with an outbox and its own network path, is less impressive in a screenshot and far better on a wrist.

Start with the smallest independent slice: last known state, one action through the outbox, one watch-sized endpoint. Add WatchConnectivity as the fast path once that works. If a feature only makes sense with the phone in hand, keep it on the phone.