DEV Community

Cover image for Building a native iOS app with AI agents, where every rule has to fail something
Raul Andrade
Raul Andrade

Posted on AI-assisted

Building a native iOS app with AI agents, where every rule has to fail something

I wanted to see what happens when you build with AI agents on a project you can't throw away: a native iOS app on the App Store, used by real people.

It's called murm. You pick 20, 30, 40 photos, and murm lays out the pages of your carousel with paper, frames and stickers. No account, right on your iPhone.

murm on iPhone: choosing a 4:5 format, picking 3 photos, tapping Build carousel, and the finished scrapbook page

murm on the App Store

From the first commit on October 9 to today:

  • about 7 weeks and more than 420 merged pull requests
  • 28 builds on TestFlight
  • my Swift experience before this: almost none. I worked as a mobile developer with React Native, and I write TypeScript, Rust and Go.

I wrote one or two of those PRs by hand, because I wanted to. AI agents wrote the rest. What kept the code from turning into a mess were the checks I built around the agents.

An agent starts every session knowing nothing about the project. Telling it the rules isn't enough: it forgets them, or bends them when a test is in the way. So if a rule matters, breaking it has to fail something: a test, a check or a hook.

1. Every rule has an ID, and the ID goes everywhere

The repo has a docs/ folder with the product contracts: the user journey, the rules that apply everywhere, and one brief per feature. Each rule has a short ID:

  • F3: the automatic layout never cuts a face with the edge of a frame or a page.
  • F5: all randomness comes from a seed saved in the project.
  • I4: the screen and the export use the same drawing function.
  • M3: a saved photo is at most 2560 px on its long side, and a smaller one is never enlarged.

The ID goes in the name of the test that proves the rule:

func test_F5_sameSeedSameHash() { ... }
func test_F3_faceNeverCut() { ... }
Enter fullscreen mode Exit fullscreen mode

A script checks that every ID cited in code, tests and commits exists in the docs, and that each one is defined only once. If an agent invents an ID, the check fails. And when I change F3, grep F3 shows me everything that depends on it.

2. Determinism, checked by a grep and a diff

The engine that lays out the pages has to be deterministic: the same photos and the same seed give the same carousel, pixel for pixel. Without that, I can't reproduce a bug from its seed, and a test that compares pages can pass on one run and fail on the next.

Agents like to reach for .random(), Date() and UUID(). So:

  • A check fails if any of them shows up in the engine or the drawing code. All randomness goes through one seeded generator, with its own seed for each page.
  • A second check lays out the same pages in two separate processes and compares the PNGs. This one catches the subtle case: Swift changes the iteration order of Set and Dictionary from one process to the next. Loop over a dictionary while placing photos, and the same seed gives a different page.

Three rendered murm pages side by side: seed 7 run twice gives the same page and the same hash; seed 8 gives a different page

Same photos, same seed, two separate processes: identical hash. A different seed gives a different page.

3. Packages that can't import UIKit

PHPicker ──▶ MurmMedia ──▶ MurmEngine ──▶ MurmStore ──▶ MurmRender
 (App)       resizes +      lays out      saves every    draws the page
             Vision once    the pages     change (undo)  (screen + export)
Enter fullscreen mode Exit fullscreen mode

Every package except the app is plain Swift, with no UIKit and no SwiftUI. The engine doesn't even import Vision: it receives faces and subjects as plain data.

A script reads the import graph and fails if that changes. It looks like bureaucracy, but it pays off:

  • The whole engine runs on the Mac, in a command-line tool, without a simulator. I tuned the look against real photo dumps on my laptop, in seconds. Those photos never go into git or any service; tests use only synthetic images, and there's a check for that too.
  • An agent can't take a shortcut and call UIKit from the engine. The check won't let it.

In TypeScript terms: Swift packages are like workspaces in a monorepo, and this rule is an ESLint no-restricted-imports you can't turn off.

4. Hooks that block known mistakes

I use Claude Code, which has hooks. The ones I kept:

  • Each edited .swift file is formatted right away, so reviews don't fill up with formatting.
  • When the agent ends its turn, the graph, rule and lint checks run (about 2 seconds). If one fails, the agent fixes it before it can say it's done.
  • Before each shell command, a small Python script blocks three things that went wrong before: git add -A (I drop unfinished assets into the repo folder, and they ended up in a commit), git reset --soft main (it quietly undid work merged in the meantime), and unquoted heredocs, one of which ran a command inside backticks in a commit message.

Each of these started as a real accident. The rule I follow now: the first time, I write the rule down. Only when the same mistake comes back in a different PR does it get a check. Otherwise I'd have more checks than code.

5. A second AI reviews every PR

When a PR opens, a hook starts an independent review by a different model, Codex, which leaves its comments on the PR. The agent that wrote the code reads those comments and fixes them. Then I review, merge and test on my phone.

My favorite catch: Claude wrote a test to prove that a project opens the same after an app update. It compared the position of each piece on the page. Codex pointed out that the test would still pass if the update lost or swapped the photos, as long as the frames stayed in place. The fix compares the page pixels and a hash of each photo file before and after the update.

The update proof only compares generic labels and the rounded rectangles of the pieces. If the update keeps the geometry but loses the photo files or changes their content, the comparison can still pass, even after Undo/Redo.

— Codex, reviewing the PR

6. Feedback no check would catch

The bar I set early was simple: can someone use it without asking me anything? TestFlight feedback turned into issues, then short briefs, then PRs.

Some of it no check could ever catch. Starting a project used to be one screen: Automatic or Blank, plus background, sticker theme and number of pages. Every rule passed. But it felt like filling out a form. What people asked for was to see ready-made templates right on the home screen and start from one. That became the new home.

What didn't work

For a while, Codex reviewed each PR using the review instructions from the PR's own branch. So a PR could loosen the rule that was judging it, and the review would follow the looser rule. Nobody did it on purpose, but nothing stopped it either. Now the reviewer reads its instructions from the base branch, and a PR that loosens a rule or removes a check gets flagged until I approve it. It's still not airtight: the checks themselves run from the PR's branch.

Learning Swift turned out to be the easy part. Most of my time went into deciding the rules.

murm is on the App Store. And if you want the small, disposable version of this experiment, I wrote about building an ASCII art converter using only prompts.

Do you have a check or a hook that exists because of a real accident? I'd like to hear the story.

Top comments (3)

Collapse
 
xenoci_com profile image
xenoci.com •

The rule-ID-in-the-test-name trick is great, and the "invented ID fails the check" part is what makes it hold up with agents. One rule I'd add to that set from running agents on an iOS app: the build number. Agents happily bump it in one place (Info.plist or the project) and not the other, or two branches bump from the same base, and you only find out when App Store Connect rejects the upload as a duplicate. A check that derives the build number from the commit count or CI run number, and fails if anything in the repo hardcodes one, removed a whole class of "upload failed" surprises.

With 28 TestFlight builds in 7 weeks, did the agents also handle the upload step, or was that the part you kept by hand?

Collapse
 
andraderaul profile image
Raul Andrade •

Thanks! The build number problem is real, and it's exactly the kind of thing that should be a check instead of a note in a doc. In murm it lives in one file and everything else reads from it.

On the upload: yes, the agent sends the build to TestFlight. Anything that touches the App Store waits for my OK, and I'm the one who presses release. Curious how you handle it on your side?

Collapse
 
xenoci_com profile image
xenoci.com •

Pretty close to yours. The agent builds, signs and uploads to TestFlight on its own; anything that changes the live listing or submits for review waits for a human. The one extra guard that paid off: the upload step refuses to run if the build's signing team or bundle ID differs from the last accepted build, since that's the mistake an agent makes quietly and Apple reports late.