ios-swiftui-screen
Skill1 starsChanged 15 days agoMITView on GitHub
Build or change a SwiftUI screen in this iOS 16 codebase — view model, loading/empty/error states, forms, navigation, accessibility and Dynamic Type. Use when asked to add a screen, list, detail page, form, sheet or tab, to fix how a screen behaves while loading or failing, or to make a screen accessible. Also use when a screen must keep working offline from the user's point of view.
In this repository37 other files it gives its agents.
- AGENTS.mdAGENTS.md
- ios-accessibility-auditSkill
- ios-api-contract-migrationSkill
- ios-api-endpointSkill
- ios-app-intents-siriSkill
- ios-bug-triageSkill
- ios-build-configurationSkill
- ios-cloudkit-syncSkill
- ios-combine-patternsSkill
- ios-commit-and-prSkill
- ios-commitSkill
- ios-concurrency-auditSkill
- ios-coreml-apple-intelligenceSkill
- ios-deep-linkingSkill
- ios-dependency-assessmentSkill
- ios-design-fixSkill
- ios-feature-moduleSkill
- ios-knowledge-baseSkill
- ios-latest-os-adoptionSkill
- ios-localizationSkill
- ios-offline-writeSkill
- ios-performance-tuningSkill
- ios-port-from-androidSkill
- ios-port-to-androidSkill
- ios-precommitSkill
- ios-privacy-complianceSkill
- ios-push-and-background-tasksSkill
- ios-refactorSkill
- ios-release-prepSkill
- ios-sdk-upgradeSkill
- ios-secure-reviewSkill
- ios-storekit-subscriptionsSkill
- ios-swift6-concurrency-migrationSkill
- ios-swiftdataSkill
- ios-swift-testing-migrationSkill
- ios-unit-testsSkill
- ios-widgetkit-live-activitiesSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 36
Every catch: guard error.isCancellation == false else { return }, then AppError.from(error).
- Very specific: line 51
Never read a @StateObject's wrapped value inside init — pull seed values from the parameter before wrapping it.
- Distinctive: line 79
No fixed heights on anything containing text.
- Distinctive: line 81
Never encode meaning in colour alone — the status chip carries text too.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Build a screen
The split
- View: layout, bindings, and calls into the view model. Nothing else — no
Taskthat does work, no formatting rules, no decisions about what to fetch. - View model:
@MainActor final class ... : ObservableObject, oneLoadStatefor primary content,banner: AppError?for non-blocking failures, and presentation helpers (formatted strings, derived flags).
iOS 16 constraints
Banned (iOS 17+): @Observable, ContentUnavailableView,
onChange(of:initial:), SwiftData, .scrollTargetBehavior,
.containerRelativeFrame.
Available and preferred: NavigationStack, .searchable, .refreshable,
.task, TextField(_:text:axis:), lineLimit(_:) with a range,
.confirmationDialog, Grid, AnyLayout, ShareLink.
onChange(of:) in iOS 16 takes the new value only:
.onChange(of: value) { newValue in ... }.
Steps
- View model — copy
WidgetListViewModel(list) orWidgetEditorViewModel(form). Key points:@Published private(set) var state: LoadState<...>; mutate only here.- First appearance:
.cacheFirst(maxAge:)for instant paint, then.remoteFirstto freshen. - Every catch:
guard error.isCancellation == false else { return }, thenAppError.from(error). - A failed refresh with content on screen sets
bannerand keeps the content. - Debounce search with a cancellable
Taskand ~350 ms sleep.
View shell
@StateObject private var viewModel: WidgetListViewModel init(viewModel: WidgetListViewModel) { _viewModel = StateObject(wrappedValue: viewModel) }Never read a
@StateObject's wrapped value insideinit— pull seed values from the parameter before wrapping it.States — wrap content in
LoadStateView, which handles loading, empty, error and retry consistently. Do not hand-roll the four branches.LoadStateView( state: viewModel.state, emptyMessage: "No widgets yet.", isEmpty: { $0.isEmpty }, retry: { await viewModel.retry() } ) { widgets in list(widgets) }- Forms — bind straight to a draft on the view model
(
$viewModel.draft.title). Disable Save withcanSave. Optional strings need an explicitBindingthat maps empty tonil. Use.interactiveDismissDisabled(viewModel.hasUnsavedChanges). - Presentation — one piece of state for "which sheet is showing", using an
Identifiablemode enum and.sheet(item:). - Accessibility — required, not optional:
.accessibilityLabelon every icon-only control..accessibilityElement(children: .combine)on composite rows.- No fixed heights on anything containing text; test at the largest Dynamic Type size.
- Never encode meaning in colour alone — the status chip carries text too.
- Announce state changes that matter (a queued save, a failed sync).
- Copy — sentence case, British English, no exclamation marks, no blame. All
error text comes from
AppError, never written inline in the view.
Verification
- No iOS 17+ API.
- Loading, empty, error and offline states all render sensibly — check each.
- A failed refresh does not blank out content the user was reading.
- Cancellation never appears as an error.
- Icon-only buttons have labels; rows combine for VoiceOver.
- Layout survives the largest Dynamic Type size.
- The view contains no business logic and no direct data access.
- A preview exists in
PreviewSupport.swiftor beside the view, usingPreviewWidgetRepository-style doubles and invented data only.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

