Modernizing an iOS feature behind a compatibility boundary

← Back to Blog & Articles

The unit of work is one seam. The durable artifact is a characterization test written before the change. The chief hazard is an implicit behavior that the new code silently stops providing.

Trace a load through the adapter: the screen starts a task, the loader installs a continuation in the box, calls the legacy service, and stores the handle. A callback completes the box; a cancellation cancels the handle and resumes with a cancellation error. Ownership is clear. The loader owns the bridge, the box owns exactly-once, and the legacy service owns the work.

Record the baseline with swift test --filter JobDetailLoaderTests. Write a characterization test for a behavior of your own legacy service before touching it. Then wrap it behind a protocol and confirm the test still passes against the wrapper.

Compare old and new behavior line by line for implicit duties: cancellation, threading, ordering, error mapping, and repeated callbacks. For every duty the old code performed, find where the new code does it or the test that proves it no longer matters.

When a migrated screen misbehaves, reproduce with a fake that completes late and one that completes twice. If either misbehaves, the adapter dropped a duty. Add the case to the characterization tests, then fix.

Legacy code often holds old habits: tokens in user defaults, logging of payloads, trust of local files. Inventory them before migrating, and move each to the current practice as its own labelled task. Review unchecked sendable annotations and manual locks as security-relevant code.

Run characterization tests against the old and the new implementation and require identical results. Test migrations against real files of each old format. Test adapters with late, duplicate, and pre-cancelled completions.

Keep an inventory file with owners and status. Give every compatibility shim an owner and a deletion date, and review the list monthly. Limit migration tasks to one seam each.

  • Legacy code sits behind a protocol before it is changed.
  • Characterization tests exist and passed before the change.
  • Every shim has an owner and a deletion date.
  • Migrations keep a backup and refuse newer versions.
  • Adapters preserve cancellation and single resumption.
  • Why must a characterization test be written before the change?
  • What does the box protect against that a plain continuation does not?
  • Why does the store refuse a newer schema instead of reading what it can?
  • How would you decide which screen to migrate first?

Continue with the book

Explore the full treatment, worked examples, and exercises in Agentic iOS App Development.


Companion article for Agentic iOS App Development, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.

Scroll to Top