One SwiftUI layout, three native idioms — keeping an AI agent from shipping "iPhone UI with a bigger window" on Mac and iPad

Posting this here rather than dev.to because I think the actual interesting part of this story is a Swift problem, not a marketing one: what happens to platform idiom — tab bar vs. sidebar, stacked panes vs. side-by-side, a titled window vs. no window at all — once the thing writing your SwiftUI is an AI agent instead of you.

Quick context for anyone who hasn't run into DesignFoundation (MIT, free) or DesignFoundationPro (paid) before: they're a token-based SwiftUI design system and a set of pre-built screens/shells on top of it, both built for iOS 18+/macOS 15+/visionOS 2+. I've written about the component library itself and about the AI-instruction-file angle elsewhere. This post is narrower, and I haven't covered it before: what it actually takes to get platform-correct UI out of an agent, and why that's a harder problem than "does the button look right."

The failure mode that doesn't show up in a screenshot

Ask an agent — Claude Code, Cursor, whatever — to build a settings screen, and it'll produce something that compiles and looks plausible on whichever simulator it's picturing. Usually iPhone. Run that same view on iPad and it's a phone screen stretched wide. Run it on Mac and there's no menu bar integration, no resizable window behavior, nothing that reads as "a Mac app" instead of "an iOS app someone recompiled." None of this throws a compiler error. None of it shows up if you only ever check the one simulator you asked for. It just quietly ships as a worse app on two of your three target platforms.

The reason this is a harder problem for an agent than component selection is that there's no API to call to fix it. You can hallucinate a wrong DFButton call and the compiler tells you. You can't hallucinate your way into knowing that a Mac sidebar app shouldn't use a bottom tab bar — that's a judgment about platform convention, and an agent has no HIG internalized unless something hands it the rule explicitly.

What "no #if os() required" actually buys you

Both packages' CLAUDE.md/AGENTS.md files state this directly, and it's a real constraint on the implementation, not just a claim:

You do not need #if os(macOS) or #if os(iOS) to use any DF or Pro component. Platform differences are handled internally via DFPlatformContext.

Concretely, DFPlatformContext is injected automatically by .dfTheme()/.dfThemePreset() and exposes idiom, horizontalSizeClass, isLiquidGlassAvailable, and toolbarVerticalEdge (for iPhone Duo — nil before Xcode 27.1) to any custom style that needs them. DFSidebar, DFTabBar, every overlay modifier — they read that context themselves and adapt. The clearest example is one specific Pro shell:

// DFAdaptiveShell — tabs on iPhone, sidebar on iPad/Mac, same call site
DFAdaptiveShell(
    tabs: [DFAdaptiveTab(id: "home", label: "Home", icon: "house")],
    selectedTabID: $selection
) { tabID in DetailView(id: tabID) }

That's the whole call. The agent doesn't branch on idiom, doesn't write a Mac-specific sidebar and an iPhone-specific tab bar and a conditional to pick between them — it writes one call, and the idiom decision happens inside the component based on where it's actually running. For a Swift dev, that's a mildly interesting abstraction. For an agent with no HIG knowledge and no way to test on three simulators in one pass, it's the difference between "possibly wrong" and "structurally can't be wrong," because the wrong branch was never generated to begin with.

Where this gets genuinely hard: iPhone Duo

The newer wrinkle, and the one I think is most relevant to this forum specifically, is Apple's dual-display iPhone Duo. Pro ships six purpose-built two-pane layouts (News, CRM, e-commerce orders, project management, documents, AI chat — the last two land in the release after 2.4.0) on one shared container:

DFDuoMasterDetail(hasSelection: false, onBack: { }, placeholderTitle: "Nothing selected") {
    MasterView()
} detail: {
    DetailView()
}

The pane logic is a pure, testable function, not a pile of GeometryReader guesswork:

let mode: DFDuoPaneMode = DFDuoLayoutRules.mode(isSplit: false, width: 390)   // .single
let showsMaster: Bool = DFDuoLayoutRules.showsMaster(mode: mode, hasSelection: true)

On Xcode 27.1+ it splits around the fold; on everything earlier it's a plain stack, with zero availability guard needed in your own code. This is the kind of thing where I'd genuinely be curious what people building for Duo are doing without something like this — hand-rolling the fold detection seems like exactly the sort of logic that's easy to get subtly wrong and annoying to test.

Being straight about what isn't proven yet

Worth saying plainly, because the docs say it plainly: the macOS NSPanel window path and the visionOS overlay fallback for the popup system compile but haven't been runtime-exercised — that's in the CHANGELOG, not something I'm softening. iOS is the verified path. If you're building for Mac or Vision Pro specifically, that's the one place I'd actually test by hand before trusting the agent's output, same as you would with any dependency's less-traveled code path.

Why I think this matters beyond this one package

The broader point, and the reason I'm posting it here instead of just linking the repo: "give the agent a component library" solves hallucinated APIs. It does not, on its own, solve platform idiom, because idiom is a convention, not a signature. If you're building anything that an agent will touch and that needs to run on more than one Apple platform, the question worth asking isn't just "does my dependency have good docs" — it's "does my dependency's AI-facing instructions actually encode idiom decisions, or does it just describe components and leave the agent to guess at layout per platform." Most libraries I've looked at do the latter.

Genuinely curious whether others here have hit the "agent ships a phone UI everywhere" problem and what you've done about it — would rather hear the counterexamples than just the agreement.