/ios-swift-skills:swift-performance-optimization-skillfrom ios-swift-skills
Investigates measured Swift/Apple-platform regressions in CPU, memory, launch, scrolling, animation hitches, image processing, energy, networking, or concurrency. Guides performance test design and Instruments experiments.
Ships in ios-swift-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Optimize from evidence. Preserve behavior, accessibility, data correctness, and lifecycle safety while changing performance characteristics.
The copy-ready examples use Xcode 16, Swift 6 language mode with strict concurrency, and iOS 17. Most principles apply to older targets; verify each API against the app's actual minimum. When comparing profiles, record the OS and toolchain used for each measurement.
Useful tools include:
| Symptom | First evidence source |
|---|---|
| CPU-bound work | Time Profiler; inspect heavy stacks and self time |
| SwiftUI update cost | SwiftUI instrument plus Time Profiler |
| Scroll or animation stalls | Animation Hitches, Core Animation, signposts |
| Growth or leaks | Allocations, Leaks, Memory Graph, memgraphs |
| Slow launch | App Launch template and launch signposts |
| Battery or thermal issues | Energy Log and device testing |
| Field regressions | MetricKit payloads and app-specific telemetry |
Use os_signpost or signposter intervals around important operations so traces answer product questions rather than only showing raw symbols.
[weak self] mechanically to every closure.weak when the owner may legitimately disappear before the callback. Use unowned only when the lifetime invariant is proven and documented; a wrong assumption traps.async functions over storing completion closures.[unowned self] in a repeating timer merely to silence a cycle.import Foundation
@MainActor
final class PollingModel {
private var task: Task<Void, Never>?
private(set) var tickCount = 0
func start() {
stop()
task = Task { [weak self] in
while !Task.isCancelled {
do {
try await Task.sleep(for: .seconds(1))
} catch {
return
}
guard let self else { return }
tickCount += 1
}
}
}
func stop() {
task?.cancel()
task = nil
}
deinit {
task?.cancel()
}
}
If a Foundation Timer is required, capture its owner weakly, store the timer, invalidate the old instance before starting another, and invalidate it on stop/deinit.
See the lifecycle-safe example.
@MainActor. Move only verified expensive, concurrency-safe work away from it.Set or dictionary can replace repeated linear membership searches.List already realizes rows lazily. ScrollView plus LazyVStack offers different styling and interaction behavior; it is not inherently faster.body evaluation is value computation, not proof that all descendants were redrawn. Use the SwiftUI instrument to identify expensive updates.body: precompute formatting, filtering, decoding, and image processing at the correct layer..equatable()/EquatableView only after measurement, and include every visible input in equality..task(id:) for work tied to a view and input. It cancels prior work when the ID changes.See the list identity example.
prepareForReuse().layoutSubviews; a one-time frame set during initialization will not follow cell resizing.See the complete downsampling and reuse example.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub fal3/swift-apple-skills --plugin ios-swift-skills14 skills in this plugin
/app-intents-widgetsDesign, implement, debug, and verify stable App Intents and WidgetKit integrations, including AppIntent, AppEntity, AppEnum, entity queries, AppShortcutsProvider, dependency injection, shared extension data, widget timelines, relevance, controls, Live Activity selection, deep links, handoff, confirmation, and privacy. Use when exposing app actions to Siri or Shortcuts, building configurable or interactive widgets, sharing state with extensions, or choosing the correct system surface for an action. Do not use for ordinary in-app buttons, generic SwiftUI layout, background scheduling without a widget or intent, SiriKit-only legacy work with no migration request, or Live Activity push-server implementation as the sole task./apple-evaluationsBuild, review, and debug generative AI quality regression suites with Apple's Evaluations framework, including Evaluation, datasets, metrics, Swift Testing integration, calibrated model judges, and tool-call trajectories. Use when measuring an Apple-platform intelligence feature, comparing prompts or models, or diagnosing misleading evaluation results. Do not use for ordinary deterministic unit tests, UI automation, performance profiling alone, model training, or an unrelated vendor's evaluation framework./cross-platform-app-development-skillUse when one Swift/SwiftUI product intentionally targets two or more of iOS, iPadOS, Mac Catalyst, macOS, watchOS, tvOS, or visionOS and needs shared-domain design, adaptive UI, capability boundaries, navigation, input, scenes, storage, or conditional compilation. Do not use for a single-platform feature or for non-Apple cross-platform frameworks./ios-accessibility-skillUse when iOS or iPadOS accessibility design, implementation, review, or testing involves VoiceOver, Voice Control, Switch Control, Full Keyboard Access, Dynamic Type, contrast, motion, focus, media alternatives, or Assistive Access. Do not use for generic visual styling or platform-neutral UI work with no accessibility requirement./ios-animation-graphics-skillDesign, implement, debug, and review accessible Apple-platform animation and graphics with SwiftUI animation, Canvas, TimelineView, matched geometry, phase/keyframe animators, Core Animation, and Lottie. Use for motion design, custom drawing, transitions, particles, animated symbols, UIKit/AppKit bridging, Reduce Motion, and animation performance. Prefer native SwiftUI for app UI; use Core Animation or Lottie only when their capabilities are needed. Do not use this skill for SpriteKit/Metal game engines, video rendering, or image editing unless animation integration is the specific task./iphone-duo-designUse when designing, adapting, implementing, or auditing an iOS app for iPhone Duo, including resizing, folding, vertical bars, reserved regions, state continuity, multiple scenes, camera behavior, and accessibility. Produce evidence-based readiness findings with SDK gates and fallbacks. Do not use for generic iPhone work without Duo or adaptive-layout requirements, Android foldables, Microsoft Surface Duo, Google Duo, or claims of Apple certification.Other plugins' skills for the same job