Short answer

An essay by a former Meta engineer argues that AI-written code holds up inside one prompt and turns fragile over months: shallow tests, extra layers, fewer people who understand it, and reviews that cannot keep up. On iOS that costs more, because every fix waits for App Review. Check your own app. Break an important function on purpose and see whether a test fails, look at your most complex files, write down how sign-in and purchases work, and read real-user crashes in Xcode's Organizer and MetricKit. In a test for this post, a suite with 100% line coverage missed four out of four planted bugs.

A short essay called "AI usage generates a fragile codebase" reached the front page of Hacker News this week and collected close to 400 points. Its author, Evan X. Merz, writes that he generated at least 90% of his code with AI in his last months at Meta and now generates all of it at his current job. He did not see a tenfold or even a twofold gain in output. What he saw instead was code that held up inside one prompt and broke down over months.

His examples come from web and backend work. The pattern he describes fits iOS apps built with Cursor, Claude Code, Rork, Bolt or Expo just as well, and an iOS app has one extra problem: you cannot hotfix it. Every repair goes back through App Review, and the users who hit the bug keep the broken build until they update. So this post takes his four causes and four warning signs and turns each one into a check you can run on your own app this week, with Xcode, MetricKit and a small shell script.

What does the essay actually claim?

Merz's core claim is that AI is good at problems that fit in its context window and careless about anything outside it. A model writing a function sees the function, the files you pasted and maybe a summary of the project. It does not see the incident from last spring, the reason a field is optional, or the three other screens that read the same cache.

He lists four ways this makes a codebase fragile:

  1. Shallow tests. The AI writes tests for trivial getters and setters, and end-to-end tests that repeat what is already covered, often for one kind of user. Line coverage looks fine while real behavior goes untested.
  2. Overly complex code. Several helper methods appear where one would do, and rules like DRY are applied so strictly that a person debugging the code has to jump through layers to follow one path.
  3. Less human understanding. When most code comes from an agent, fewer people on the team know how the system fits together, so fewer people notice when a pull request fights an existing data structure.
  4. Speed over review. Pull requests arrive faster than people can read them. Reviewers skim. Weak tests and poor names pile up.

And four signs that it has already happened: incidents become more frequent, recovery takes longer, errors show up only for real users, and the product gets worse to use. He offers no study or metric for any of this. It is one engineer's experience at two large companies, and he says so. That is a reason to measure your own app rather than take his word or dismiss it.

Why does this hit AI-built iOS apps harder?

A web team that ships a bad deploy can roll back in minutes. An iOS developer who ships a bad build has to fix it, archive, upload, wait for processing, wait for review and then wait again while users update. A crash that a web app would show for an hour can sit on phones for a week. Why Your AI-Built App Sits in Waiting for Review explains the review part of that wait.

Many apps built with AI tools also start from a founder who is not reading the Swift at all. Merz worries about teams where fewer people understand the code. In a solo vibe-coded app, sometimes nobody does. Plenty of these apps still work, but it means the four checks below matter more, because there is no senior engineer down the hall who remembers why something was done.

Check 1: Do your tests check anything?

Start with coverage, then distrust it. Apple's own documentation on code coverage says that coverage alone does not ensure your tests "are doing their job". That is the exact gap Merz describes.

To turn coverage on, open your test plan from the Project navigator or the scheme editor, click the Configurations tab, choose Shared Settings, scroll to Code Coverage and tick "Gather coverage for", then pick your app target. After a test run, the Coverage pane of the Report navigator lists files and functions with a percentage for each, and the source editor highlights lines that never ran.

From the command line the same data comes out of the result bundle:

xcodebuild test \
  -scheme YourApp \
  -destination 'platform=iOS Simulator,name=iPhone 17' \
  -enableCodeCoverage YES \
  -resultBundlePath build/Tests.xcresult

xcrun xccov view --report --only-targets build/Tests.xcresult

Change the simulator name to one you have installed. Now look at the number with suspicion. A high percentage made of tests like this one tells you almost nothing:

func testTotal() {
    var cart = Cart()
    cart.total = 5
    XCTAssertEqual(cart.total, 5)
}

That test sets a property and reads it back. It passes whatever your checkout logic does. Coverage counts the line as tested anyway. The other common pattern in agent-written suites is a test that calls a function and asserts nothing, which counts every line it touches as covered even if the function throws away an error.

A quicker way to judge a suite is to break the code on purpose. Pick the function that matters most to your money or your users: the price calculation, the subscription check, the sync merge. Flip a comparison, return early, or delete a line. Run the tests. If they still pass, those tests are decoration. This is a manual version of mutation testing, and ten minutes of it tells you more than the coverage percentage.

When you replace weak tests, write them around the cases a real user hits. Swift Testing makes it cheap to run one test over many inputs:

import Testing
@testable import YourApp

@Test(arguments: [
    (items: 0, coupon: nil as String?, expected: 0),
    (items: 3, coupon: nil, expected: 2997),
    (items: 3, coupon: "SAVE10", expected: 2697),
    (items: 1, coupon: "EXPIRED", expected: 999)
])
func cartTotal(items: Int, coupon: String?, expected: Int) {
    let cart = Cart(itemCount: items, unitPriceCents: 999, coupon: coupon)
    #expect(cart.totalCents == expected)
}

The types here are placeholders for your own. The point is the rows: an empty cart, a normal cart, a valid coupon, an expired coupon. Ask your coding agent to list the edge cases before it writes any test, then read the list yourself. You know that some users sign in with Apple and hide their email, or that your app has a guest mode. The agent does not, unless you tell it.

The break-it test, run on a small package

Here is that manual test with real output. A small Swift package was written for this post with one type, a Cart that totals its items and applies a coupon. It has two test suites. The weak one copies the patterns above: one test sets total and reads it back, and one calls price(with:) three times and asserts nothing. The strong one is a Swift Testing table with five rows: an empty cart, a normal cart, a valid coupon, an expired coupon and a 100% coupon.

Coverage was measured for each suite on its own with swift test --enable-code-coverage on Swift 6.2.3. Then four one-line changes were made to the price function, one at a time, and each suite was run against each change.

CheckWeak suiteStrong suite
Line coverage of Cart.swift17 of 17 lines, 100%17 of 17 lines, 100%
Expired-coupon check invertedNot noticedCaught
Early return that skips the couponNot noticedCaught
Minus changed to plus in the discountNot noticedCaught
>= 100 changed to > 100Not noticedNot noticed

Both suites report 100% coverage. One of them would let you ship a checkout that adds the discount to the price. That is the whole case for breaking the code on purpose: coverage could not tell these two suites apart, and four small edits could.

The last row is worth a second look. The strong suite missed it, but not because a test is missing. With a 100% coupon the normal formula already returns zero, so that line can change without changing any result. A change that survives every test means one of two things: a case you have not tested, or code that does not need to be there. Both are worth knowing.

The edits were applied by this script. It reads one sed expression per line from a file, applies it, runs the tests, reports the result and restores the file with Git.

#!/usr/bin/env bash
# break-it.sh: make one small change at a time to a source file, run the tests,
# and report whether any test noticed. Run it inside a clean Git repo.
# Usage: ./break-it.sh Sources/CartKit/Cart.swift [mutations.txt]
# Each line of mutations.txt is one sed expression.
set -u
FILE="$1"; LIST="${2:-mutations.txt}"
TEST_CMD="${TEST_CMD:-swift test}"
git diff --quiet -- "$FILE" || { echo "commit or stash your changes to $FILE first"; exit 1; }
n=0; survived=0
while IFS= read -r expr; do
  [ -z "$expr" ] && continue
  n=$((n + 1))
  sed -i.bak -E "$expr" "$FILE" && rm -f "$FILE.bak"
  if git diff --quiet -- "$FILE"; then
    echo "$n  no change  $expr"
  elif $TEST_CMD >/dev/null 2>&1; then
    echo "$n  SURVIVED   $expr"; survived=$((survived + 1))
  else
    echo "$n  caught     $expr"
  fi
  git checkout -- "$FILE"
done < "$LIST"
echo "$survived of $n changes went unnoticed by the tests"

The four expressions used here were:

s/!coupon\.expired/coupon.expired/
s/let sum = subtotal\(\)/let sum = subtotal(); if sum > 0 { return sum }/
s/sum - sum \* coupon/sum + sum * coupon/
s/percentOff >= 100/percentOff > 100/

Three limits. TEST_CMD is split on spaces, so for a command with quoted arguments, such as the xcodebuild test line above, put the command in a small script and point TEST_CMD at that. That path was not run for this post. A change that stops the code compiling also counts as caught, because the test command fails, so read the list before you trust the score. And the script only makes the changes you write down. Start with the five lines that decide money, access or saved data.

Check 2: Is the code more complicated than the job?

Merz's second cause is code that is harder to follow than it needs to be. In Swift projects written by agents this often shows up as a view model that calls a manager that calls a service that calls a repository, each one a thin wrapper, with a protocol for every layer and only one type behind each protocol.

SwiftLint already measures part of this. Its cyclomatic_complexity rule is on by default, warns at 10 and errors at 20, counting the branches in each function body. If your project does not run SwiftLint, install it with Homebrew (brew install swiftlint) and run it once from the project root with swiftlint lint. Do not fix everything it reports. Sort by the complexity warnings and look at the top five functions. Those are where the next bug will hide, because they are the paths nobody can hold in their head.

Branch count is only half of it. The other half is indirection. For one feature that matters, trace a single user action from the button tap to the network call and count how many files you open. If tapping "Save" takes you through seven files, ask whether four of them do anything. A protocol with one implementation and no test double is often there because an agent applied a pattern out of habit. Collapsing it makes the next bug easier to find.

The script further down prints the longest files and the most branch-heavy files in your repo so you know where to start reading.

Check 3: Does anyone understand the code?

This is the hardest check to automate, and the most important one for a solo founder. Here is a test you can run in an afternoon. Pick three things your app does that would hurt if they broke: signing in, buying or restoring a purchase, and whatever the core feature is. For each one, write down in plain words, without opening the code, which files are involved and where the data is stored. Then open the code and check.

Where your description was wrong, you have found a spot where you would be lost during an outage. Write the real answer into a short file in the repo, something like ARCHITECTURE.md, with one paragraph per flow. Your coding agent can draft it, but correct it yourself, because writing the corrections is how you learn the flow.

Two more questions belong here. Do you know what happens when the network drops halfway through a purchase? Do you know where your app stores the signed-in user, and whether it survives a reinstall? If the answer to either is "I would have to ask the agent", you are in the situation Merz describes.

Check 4: Do you review faster than you can read?

Merz's fourth cause is speed. An agent can produce a 900-line diff in a minute. Nobody reads 900 lines carefully. The fix is to make diffs small enough to read, and to put the checks you would skip into a script that never gets tired.

Three habits help. Ask for one change per prompt and commit after each one, so each diff fits on a screen. Before you accept a diff, read the test changes first: if the agent changed an assertion to make a test pass, stop and ask why. And keep a short list of things you always check in your own app, such as "no new try? on network or database calls" or "no secrets in source files", then run them on every change. Write Your Acceptance Criteria Before You Prompt covers how to turn that list into checks an agent can run.

That last one is worth a closer look. try? turns an error into nil, and an empty catch {} drops it completely. Both are common in generated Swift because they make the compiler stop complaining. Both also mean that when something fails for a real user, nothing is logged and the screen just shows stale or empty data. That leads straight to the first warning sign.

How do you see errors that only real users hit?

Merz's third warning sign is errors that only appear in production, because tests and developer testing do not match how people use the app. On iOS you have two Apple tools for this that cost nothing.

The first is the Crashes organizer in Xcode. Apple's documentation describes it as the place to get reports about issues customers hit in builds from the App Store and TestFlight. Open it from Window, Organizer, pick your app and look at the Crashes section after every release. A crash that appears only on one OS version or one device class is exactly the kind of bug your simulator runs never show.

The second is MetricKit, which delivers crash, hang, CPU exception and disk write diagnostics from users' devices to your own code. Apple's documentation for MXMetricManager now marks it deprecated in the iOS 27 SDK and points to MetricManager, a new class available from iOS 27. The new API is an instance you create and keep, with two async sequences, one for daily metric reports and one for diagnostic reports. Apple's docs say DiagnosticReport conforms to Codable, so you can encode it straight to JSON:

import MetricKit

@available(iOS 27.0, *)
final class Diagnostics {
    static let shared = Diagnostics()
    private let manager = MetricManager()

    func start() {
        Task {
            for await report in manager.diagnosticReports {
                switch report.result {
                case .crash, .hang:
                    upload(report)
                default:
                    break
                }
            }
        }
    }

    private func upload(_ report: DiagnosticReport) {
        guard let data = try? JSONEncoder().encode(report) else { return }
        // Send data to your own endpoint or logging service.
        print(String(decoding: data, as: UTF8.self))
    }
}

Call Diagnostics.shared.start() early in launch. Apple's docs warn against creating more than one MetricManager for the same reports, since two tasks reading the same sequence each get only part of the reports, so keep a single shared instance like the one above. They also note that MetricKit does not create a report for every event; hang reports, for example, depend on hang detection being active on the device. If your app still supports iOS 26 or earlier, keep the older MXMetricManager subscriber for those versions. Its documentation says diagnostic reports arrive immediately from iOS 15, and that you need a physical device to test it.

The one try? in that example is fine because failing to encode a diagnostic should not crash the app. What matters is whether you meant to ignore the error.

How do you tell incidents are getting worse?

Merz's first two signs are more incidents and slower recovery. A solo developer does not have an incident tracker, but you can keep a plain table in a note: date, what broke, how users found it, how long until the fix was live in the App Store. Fill it in for the last three months from memory, your reviews and your support email. Keep it going.

Two numbers from that table tell you most of what you need. If the gap between incidents is shrinking, the codebase is getting more fragile. If the time from report to fix is growing, the code is getting harder to understand. Both of those are trends, so you need a few months of rows before they mean much. App Store reviews mentioning a crash or "doesn't load" count as incidents even if nobody emailed you.

A script to find the weak spots first

Here is a small script that prints rough fragility signals for a Swift repo: test functions with no assertion, tests that read back a value they just set, the longest source files, the most branch-heavy files, and every try? or empty catch outside tests. It uses only standard shell tools. I tested it on Linux against a small fake repo; on a Mac, run it with the system bash.

#!/usr/bin/env bash
# fragile-check.sh: rough fragility signals for a Swift repo.
# Usage: ./fragile-check.sh path/to/repo
set -euo pipefail
ROOT="${1:-.}"

echo "== Test functions with no assertion =="
find "$ROOT" -name '*Tests.swift' -not -path '*/.build/*' -print0 |
while IFS= read -r -d '' f; do
  awk -v file="$f" '
    /func test[A-Za-z0-9_]*\(|@Test/ { if (name != "" && !hit) print file ": " name; name=$0; hit=0; next }
    /XCTAssert|XCTFail|XCTUnwrap|#expect|#require/ { hit=1 }
    END { if (name != "" && !hit) print file ": " name }
  ' "$f" | tr -s ' \t' ' '
done

echo
echo "== Tests that only read back a value they just set =="
grep -rnE --include='*Tests.swift' -A1 '^\s*[a-zA-Z_]+\.[a-zA-Z_]+ = ' "$ROOT" 2>/dev/null |
  grep -E 'XCTAssertEqual|#expect' | head -n 20 || true

echo
echo "== Longest Swift files (lines) =="
find "$ROOT" -name '*.swift' -not -path '*/.build/*' -not -name '*Tests.swift' -print0 |
  xargs -0 wc -l 2>/dev/null | sort -rn | grep -v ' total$' | head -n 10

echo
echo "== Branch-heavy files (if/guard/switch/case/catch/&&/|| count) =="
find "$ROOT" -name '*.swift' -not -path '*/.build/*' -not -name '*Tests.swift' -print0 |
while IFS= read -r -d '' f; do
  k=$(grep -owE 'if|guard|switch|case|catch|while' "$f" | wc -l || true)
  o=$(grep -oE '&&|\|\|' "$f" | wc -l || true)
  n=$((k + o))
  echo "$n $f"
done | sort -rn | head -n 10

echo
echo "== Silent error swallowing (try? and empty catch) =="
grep -rnE --include='*.swift' 'try\?|catch[[:space:]]*\{[[:space:]]*\}' "$ROOT" --exclude-dir=.build --exclude-dir=Pods --exclude-dir=DerivedData | grep -v 'Tests.swift' | head -n 30 || true

Save it as fragile-check.sh, run chmod +x fragile-check.sh, then ./fragile-check.sh path/to/YourApp. It counts patterns in text, so it will miss some cases and flag a few that are fine. A test whose assertion lives in a helper function will show up as having none, for example. Treat the output as a reading list. The value is that it points you at the ten files to open first instead of the four hundred you could open.

The script's output on a sample package

The script above was run on macOS 26.0.1 with the system's bash 3.2 against the sample package from Check 1, with one extra file added that contains a try? and an empty catch:

== Test functions with no assertion ==
CartKit/Tests/WeakTests/WeakTests.swift: func testPriceRuns() {

== Tests that only read back a value they just set ==
CartKit/Tests/WeakTests/WeakTests.swift-8-        XCTAssertEqual(cart.total, 5)
CartKit/Tests/StrongTests/StrongTests.swift-14-    #expect(cart.price(with: coupon) == expected)

== Longest Swift files (lines) ==
      25 CartKit/Sources/CartKit/Cart.swift
      11 CartKit/Package.swift
       4 CartKit/Sources/CartKit/IO.swift

== Branch-heavy files (if/guard/switch/case/catch/&&/|| count) ==
2 CartKit/Sources/CartKit/Cart.swift
1 CartKit/Sources/CartKit/IO.swift
0 CartKit/Package.swift

== Silent error swallowing (try? and empty catch) ==
CartKit/Sources/CartKit/IO.swift:2:func load(_ u: URL) -> Data? { try? Data(contentsOf: u) }
CartKit/Sources/CartKit/IO.swift:3:func save() { do { try run() } catch { } }

It found the test with no assertion, the read-back test and both swallowed errors. It also shows why the output is a reading list and not a verdict. The second line under "read back" is the strong, table-driven test. The script flagged it because the line before its #expect is an assignment, even though the test checks a different value. One false alarm out of two hits is a fair picture of what a text search can do.

What should you do this week?

If you only have one evening, do this in order:

  1. Turn on code coverage in your test plan and run the tests once. Note the number, then pick your most important function, break it on purpose and see whether any test fails.
  2. Run the script above and open the top three files from each section.
  3. Open the Crashes organizer for your latest App Store or TestFlight build and read every crash with more than one occurrence.
  4. Write one paragraph each for sign-in, purchases and your core feature in ARCHITECTURE.md, then check it against the code.
  5. Add MetricKit diagnostics if the app has none, so the next real-user crash reaches you even when nobody writes in.

Merz himself still generates all of his code with AI. These checks are there so that when your agent writes the next feature, you can tell whether it made the app sturdier or more fragile, before your users tell you in a one-star review.

If you use Claude Code and want a ready-made structure for the review part, my Ship It Solo: The Claude Code Agent Team Kit ($26) is a set of four subagents (spec-writer, implementer, reviewer and qa) with five slash commands, guard hooks and five playbooks, including one for test backfill. The qa agent writes and runs tests against the acceptance criteria in a spec, and the reviewer does an adversarial pass on each diff. It is markdown, JSON and bash you are expected to read, and it does not replace your own review.

FAQ

Is AI-generated code always fragile?

No. Merz's essay is one engineer's experience, and it contains no study or metrics. Plenty of AI-written code is fine. The checks here are for finding out which parts of your own app are fine and which are not.

What code coverage percentage should an iOS app have?

There is no number that makes an app safe. Apple's documentation says coverage alone does not prove your tests do their job. Coverage on the code that handles money, sign-in and user data, with tests that fail when you break that code, matters more than the overall percentage.

Should I use MetricManager or MXMetricManager?

Apple's docs mark MXMetricManager deprecated and point to MetricManager, which needs iOS 27 or later. If your app supports older iOS versions, use the new class behind an availability check and keep the old subscriber for older devices.

Do I need SwiftLint to measure complexity?

No, but it is the easiest way. Its cyclomatic_complexity rule is enabled by default with a warning at 10 and an error at 20. The script in this post gives a rough branch count per file if you do not want another tool.

Is try? always a bug?

No. It is fine where you have decided a failure does not matter. It is a problem on network, database and purchase paths, where a silent nil means a real user sees empty data and you never hear about it.

How do I know whether my tests would catch a real bug?

Change the code and see. Flip a comparison or a sign in a function that matters, run the tests, and put the code back. In a test for this post, a suite with 100% line coverage passed after all four such changes, and a five-row table test caught three of them.

Sources