ios-performance-tuning
Skill1 starsChanged 14 days agoMITView on GitHub
Diagnose and fix performance problems in this iOS app — slow launch, janky scrolling, redundant network calls, memory growth, battery drain from sync. Use when a screen feels slow, a list stutters, the app is slow to start, memory climbs, the same request fires repeatedly, or when asked to profile or optimise something.
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-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-swiftui-screenSkill
- 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, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 38
Search not debounced, so four keystrokes are four requests.
- Very specific: line 44
Keep the primary content in one LoadState and avoid publishing properties that change on every keystroke alongside it where possible.
- Very specific: line 48
Keep row views cheap: no date formatter created in body, no filtering or sorting in body.
- Very specific: line 70
Images: Not covered by this template.
≈ “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
Tune performance
Measure first. In SwiftUI, the cause of jank is almost never where it feels like it is, and an optimisation applied on a hunch usually costs readability for nothing.
Measure
| Symptom | Tool |
| Slow launch | Instruments → App Launch; check what runs in bootstrap() |
| Janky scrolling | Instruments → SwiftUI, plus Self._printChanges() in the suspect view (temporary debug aid only — an undocumented, underscore-prefixed API with no stability guarantee; strip it before committing) |
| Redundant requests | The AppLog networking category — every request logs → METHOD /path |
| Memory growth | Instruments → Allocations and Leaks; retain cycles in closures |
| Battery | Xcode Energy gauge; look at sync frequency and monitor callbacks |
Field data (MetricKit). For what real users experience, use MetricKit. On iOS 27 the
Swift-first MetricManager delivers MetricReport and DiagnosticReport values through
an AsyncStream; the original MXMetricManager/MXMetricPayload APIs still work but are
no longer recommended for new code. Keep the old subscriber for OS versions before 27. If
the app references ScrollHitchTimeMetric or scrollHitchTime(_:), recompile with the
iOS 27 SDK and move to HitchTimeMetric — otherwise it crashes at launch on iOS 27.
Xcode 27's Organizer also adds an Insights Overview of regressions.
Note the number before and after. "It feels better" is not a result.
The usual causes in this architecture
- Redundant fetches.
onAppear()guards oncase .idlefor a reason — remove that guard and every tab switch refetches. Check:.taskon a row triggering paging more than once (loadMoreIfNeededguards onisLoadingMore).- Search not debounced, so four keystrokes are four requests.
- Two view models built for the same screen because the view was recreated —
@StateObject, not@ObservedObject, for owned view models.
- Whole-list invalidation.
ObservableObjectinvalidates the view on any@Publishedchange. So:- Keep the primary content in one
LoadStateand avoid publishing properties that change on every keystroke alongside it where possible. - Give
ForEachstable identity (Identifiablewith a real id, never.indices). - Keep row views cheap: no date formatter created in
body, no filtering or sorting inbody. Precompute in the view model.
- Keep the primary content in one
- Formatter and encoder churn.
DateFormatterandJSONEncoderare expensive to create. This project keeps them as statics (JSONDecoder.api,ISO8601DateFormatter.api). Never construct one insidebodyor inside a loop. - Cache writes on the hot path.
FileCacheStorewrites whole JSON files. For a large collection, write once per fetch rather than per item, and consider caching only the first page or two — a user who is offline needs the recent screens, not everything. - Launch work.
AppEnvironment.bootstrap()runs before the first screen. It should do the minimum: restore the session, start the monitor, count pending items. Draining the outbox is fine because it is awaited off the critical path; anything that blocks the first paint is not. - Sync frequency. Sync is triggered by connectivity returning, the app becoming active, and explicit refresh — deliberately not a timer. Do not add one; a repeating timer that fires while offline burns battery for nothing.
- Images. Not covered by this template. If images arrive, add a bounded cache
with downsampling before decode (
CGImageSourceCreateThumbnailAtIndex) — full resolution decoded into a 60-point row is the most common memory bug in list screens.
Retain cycles to check
Task { }inside a view model capturingselfstrongly and outliving it — use[weak self]for anything long-running.- Closures stored as properties (
onSignedOut,setStateHandler) — both use[weak self]at the capture site; keep it that way. NWPathMonitor.pathUpdateHandlercapturingself— already[weak self].
Verification
- A measurement before and after, with the numbers stated.
- The fix addresses what the measurement showed, not what you guessed.
- No readability sacrificed for an unmeasured gain.
- Request count for the scenario checked in the networking log — no duplicates.
- Memory stable after ten navigations in and out of the screen.
- No new caching layer added without a cap and an eviction story.
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.

