agentsclimarketplace

Ios performance audit

Skill almasumdev/awesome-ios-agent-skills/.github/skills/performance/ios-performance-audit

Expert guidance on auditing iOS runtime performance using Instruments (Time Profiler, Hangs, Allocations), SwiftUI view rebuild analysis, and common fix patterns. Use when the app feels slow or drops frames.From its SKILL.md

Install
npx -y skills add almasumdev/awesome-ios-agent-skills --skill ios-performance-audit

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

5.4 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it

iOS Performance Audit

Instructions

Measure first, optimize second. Instruments and Xcode's built-in tooling pinpoint real hot paths so you don't rewrite code that isn't the problem.

1. Pick the Right Instrument

SymptomInstrument / Tool
Slow scrolling / jankTime Profiler, Animation Hitches
UI freezes / spinning beachballHangs, Main Thread Checker
Memory growthAllocations, Leaks
Excessive network trafficNetwork
Battery / energy drainEnergy Log on device
Slow startupApp Launch (see ios-app-launch)
SwiftUI excessive rebuilds_printChanges(), SwiftUI instrument

Profile Release builds on a physical device — simulators lie.

2. Time Profiler Workflow

  1. Edit scheme → Profile action → Build Configuration: Release.
  2. Product → Profile (⌘I) → Time Profiler.
  3. Record the slow flow.
  4. In the call tree, enable Invert Call Tree, Hide System Libraries, Top Functions.
  5. Expand to the hottest user-code frame. That's the target.

Look for:

  • Main-thread JSON decoding → move to a background Task or an actor.
  • Unnecessary work in body → extract, memoize, or move to model.
  • Date / DateFormatter allocations in loops → cache formatters.
  • String slicing / regex in tight loops → precompile.

3. Hangs

A hang is any main-thread block > 250 ms. Enable Hangs:

Debug → Debug Workflow → Always Show Disassembly (optional)
Product → Profile → Hangs

Typical causes: synchronous disk reads, Core Data fetches on the main context, JSON decoding, layout thrash. Move them off the main actor:

@MainActor
func onAppear() {
    Task.detached(priority: .userInitiated) {
        let articles = try await repository.latest()
        await MainActor.run { self.articles = articles }
    }
}

4. SwiftUI Rebuild Audit

Print what changes caused a re-evaluation of body:

struct ArticleList: View {
    let articles: [Article]
    var body: some View {
        let _ = Self._printChanges()
        ForEach(articles) { ArticleRow(article: $0) }
    }
}

Common fixes:

  • Pass values, not models, into child views.
  • Split big views so state changes affect a small subtree.
  • Make expensive views Equatable and wrap in EquatableView where needed.
  • Avoid reading unrelated @Observable properties in body.
  • Replace AnyView with concrete types.

5. List Performance

  • Use List or LazyVStack — not ForEach inside VStack for long content.
  • Ensure stable id (prefer Identifiable). Avoid .id(UUID()) reseeding.
  • Keep row views cheap: image decoding off-main, .drawingGroup() only if profiled.

6. Image Pipeline

  • Decode and resize to the target pixel size before drawing — don't hand a 4000×3000 image to a 60-point thumbnail view.
  • Use AsyncImage for remote URLs; for custom flows, cache UIImage in memory.
  • Consider ImageRenderer for snapshot generation off-main.
func thumbnail(for data: Data, side: CGFloat, scale: CGFloat) async -> UIImage? {
    await Task.detached(priority: .utility) {
        let opts: [CFString: Any] = [
            kCGImageSourceCreateThumbnailFromImageAlways: true,
            kCGImageSourceThumbnailMaxPixelSize: side * scale
        ]
        guard let src = CGImageSourceCreateWithData(data as CFData, nil),
              let cg = CGImageSourceCreateThumbnailAtIndex(src, 0, opts as CFDictionary)
        else { return nil }
        return UIImage(cgImage: cg, scale: scale, orientation: .up)
    }.value
}

7. Memory

  • Run Leaks and Allocations. Filter by your module.
  • Watch for retain cycles: [weak self] in Task { } is rarely needed (tasks end), but it matters in long-lived closures (Combine sinks, delegate blocks).
  • Use Memory Graph Debugger (Debug → Debug Memory Graph) to find cycles interactively.

8. Frame Rate & ProMotion

Target 120 Hz on ProMotion devices. Avoid animating views that force layout every frame. Prefer offset, opacity, scale transforms over size/frame animations on layout-heavy hierarchies.

9. Logging Hangs in Production

Use MetricKit to collect hang and launch metrics from real users:

import MetricKit

final class MetricsObserver: NSObject, MXMetricManagerSubscriber {
    func didReceive(_ payloads: [MXMetricPayload]) { /* upload */ }
    func didReceive(_ payloads: [MXDiagnosticPayload]) { /* hang traces */ }
}

Checklist

  • All profiling is done on a physical device, Release build.
  • Time Profiler trace saved for the slow flow with identified hot frame.
  • No work > 16 ms on the main actor during scrolling.
  • SwiftUI views pass _printChanges review for target screens.
  • Images are decoded/resized to target size before display.
  • Memory graph shows no retain cycles in visited flows.
  • MetricKit wired up for production hang / launch monitoring.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,871. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.