Skip to main content
Zubin KhavarianZubin Khavarian

Porting Two Web Apps to SwiftUI with an Agent

· 4 min read · #ios #swift #agents

Editorial illustration of a little rust boat with a sail carrying two app-icon tiles across pale blue water, from a dock shaped like a browser window to a harbour shaped like a phone, a dotted route arcing above, every edge drawn in wobbly ink.

Two of my learning apps started life on the web: a math drill and a music-reading game. They were React apps, and they worked. But the people who’d use them most, children on family iPads, find apps through the App Store, and a web app never feels quite at home there.

So in late September I ported both to native SwiftUI, working with a coding agent. The first native commit landed on September 23. On September 24 I deleted the web apps.

Treble Trouble12,995 lines55 commits since Sep 23Mathness12,294 lines40 commits since Sep 24Sep 24: web apps removed, 290 files, 44,341 linesevery one still recoverable with git show <sha>:<path>
Two native apps, about 25,300 lines of Swift, started a day apart. The web versions were deleted on day two.

This isn’t a post about how clever the agent was. It’s about the few decisions that made a fast port safe, and the ones I’d make again.

Write the port map down

The single most useful thing was a port map: for every web file, the Swift file it becomes. Not in my head, not in a planning chat, but in each app’s AGENTS.md, the notes file the agent reads before it touches anything.

web (TypeScript)iOS (SwiftUI)lessons.tsLearn/Lessons.swiftproblems.tsLearn/Problems.swiftrhythm.tsMusic/Rhythm.swiftnext-question.tsGame/Question.swiftstaff-symbol.tsxComponents/Staff/*session.tsState/Session.swift
Part of Treble Trouble's port map. Every web file has a named Swift home, written down where the agent reads it.

A port map does three jobs at once. It tells the agent where new code belongs, so the Swift project ends up organized rather than accreted. It lets a reviewer (me) check a change against the original file it’s meant to replace. And it makes the port finite: when every row has a Swift home, the port is done.

One source of truth, and a way back

Running two versions of the same app in parallel is where ports go to die: every fix has to be made twice, and they drift. So each app’s notes say it plainly: the web app is gone, and the Swift code is the source of truth.

Deleting the web apps on day two sounds reckless, but it wasn’t, because nothing was really lost. The notes record the exact commit to recover any file from:

git show bec9aae8:apps/treble-trouble/src/rhythm.ts

That one line is what made deleting 290 files comfortable. When the agent (or I) wanted to check how the web version handled something, the original was one command away, and there was never a second copy to keep in sync.

Keep the names

A few things were kept deliberately identical: lesson ids, the names of the keys that store progress, and the translation catalogs, which moved over as the same JSON files (L("English message") looks up the same strings on both platforms).

Keeping names stable kept the port map honest. A lesson id means the same lesson on both sides of the map, so a test, a screenshot flag or a note in the docs doesn’t need translating.

Translate the logic, rethink the platform

The logic moved over almost line for line: how questions are generated and how lessons unlock. That’s the part an agent is very good at, and the part where a port map keeps it faithful.

The parts that touch the platform are different, and they’re where I spent my own attention:

carried overlesson and question logiclesson idsstorage key namestranslation catalogsrethoughtone audio callbacktab bar navigationStoreKit, grown-up gateleft behindkeyboard answersrotate prompttop-edge mode tabspaper grain texture
The logic moved over almost line for line. The parts that touch the platform were redesigned, and a few web-only pieces were simply dropped.
  • Audio. The web music app ran everything through one AudioContext. The iOS version keeps that idea and routes every sound through one render callback, rather than translating it into a handful of separate players.
  • Navigation. The web apps had mode tabs across the top and a big title menu. The native apps use a tab bar and a splash screen, because that’s what an iPad app is.
  • Everything the web didn’t need. In-app purchases through StoreKit, a grown-up check in front of every link, optional player profiles, App Store screenshots.

And some things were simply left behind: answering questions with the keyboard (a desktop-only feature on the web), a “please rotate your device” prompt (iOS just rotates), and a paper grain texture.

What the agent needed from me

Looking back, the agent needed the same things a new teammate would:

  • A map of where things go, written down.
  • A clear rule about which version is real.
  • A way to look at the old code, without keeping it alive.
  • Stable names, so references mean the same thing everywhere.
  • Judgement on the platform-specific parts, which is where “translate this file” stops being the right instruction.

The logic took days. The judgement calls about audio and navigation are what made the results feel like iPad apps rather than web pages in a frame.

Get new posts by email

One short email when a post goes out, about once a week. Unsubscribe any time.

Or follow along:RSSGitHubX

Zubin Khavarian, Software EngineerWritten by
READ~/blog/porting-web-apps-to-swiftui~4 min0%
zubin@zubin.dev: man keys

// go to

  • ghhome
  • gwwriting
  • gaapps
  • gpprojects
  • goopen source
  • gnnow
  • guuses

// move

  • jscroll down
  • kscroll up
  • ggtop of page
  • Gbottom of page
  • }next section (posts)
  • {previous section (posts)
  • ]newer post
  • [older post

// do

  • ⌘Ksearch everything
  • /search, too
  • ttoggle light / dark
  • ?this sheet
  • escclose