Agent skills for iOS, iPadOS, Swift, SwiftUI, and modern Apple framework development.
71
89%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Advisory
Suggest reviewing before use
Context: Apple guidance on identifying hangs caused by long-running main-thread work and understanding the main run loop.
A hang is a noticeable delay in a discrete interaction. Apple commonly frames this as main-thread busy time long enough for the user to feel the UI stop responding.
Practical thresholds:
The important point is not the exact number. A hang is user-perceived blocked interaction, and the main thread is usually where the problem lives.
A typical interaction flows through three stages on the main thread:
If any one of those stages runs too long, the main run loop cannot get back to sleep and cannot service the next event in time.
The main run loop is a good mental model for hangs:
@MainActor
is a correctness tool, not a performance optimization.If the UI is stalled, assume the main thread is overloaded until profiling proves otherwise.
Start with one specific symptom:
Avoid broad goals like "the app feels slow" until you isolate a single path.
Use the Hangs instrument, and pair it with Time Profiler when needed.
Good capture setup:
Look for long busy periods instead of staring at total CPU first.
Questions to answer:
A useful fix removes or re-locates expensive work. A weak fix only hides the stall behind a spinner while the main thread still does too much.
Typical offenders:
// DON'T
Button("Open") {
let data = try? Data(contentsOf: fileURL)
model = parse(data)
}
// DO
Button("Open") {
Task {
let data = try await loadFileData()
let parsed = try await parseModel(from: data)
await MainActor.run { model = parsed }
}
}A tap handler should kick off work, not do all the work inline.
// DON'T
func didTapRefresh() {
items = expensiveRebuildOfEntireList()
}
// DO
func didTapRefresh() {
Task {
let rebuilt = await rebuildList()
await MainActor.run { items = rebuilt }
}
}SwiftUI and UIKit/AppKit can both stall if the view tree triggers too much work per interaction.
Watch for:
bodyA hang may show up as main-thread waiting, not main-thread computing.
Examples:
If high-priority UI work is waiting on lower-priority work that holds a needed resource, the UI still feels hung even if the main thread stack looks shallow.
Prefer this split:
// DON'T
Text(distanceFormatter.string(from: trip.distance))
// DO
Text(trip.formattedDistance)If the value changes rarely, compute it at the model boundary.
When practical, render partial state first and append or replace as work finishes.
A common hang pattern is doing unnecessary work for content the user already navigated away from.
.task(id: searchQuery) {
results = []
results = await search(query: searchQuery)
}Pair this with cancellation inside the async work.
After a fix, confirm all of the following:
If the hang disappears but scrolling or animation gets worse elsewhere, the work likely just moved rather than improved.
SwiftUI-specific hangs often come from:
Use the SwiftUI Instrument when the symptom is tied to view updates or layout. Use the Hangs instrument when the symptom is broad UI unresponsiveness and you first need to confirm the main thread is blocked.
skills
accessorysetupkit
references
activitykit
references
adattributionkit
references
alarmkit
references
app-clips
app-intents
references
app-store-optimization
app-store-review
apple-on-device-ai
appmigrationkit
references
audioaccessorykit
references
authentication
references
avkit
references
background-processing
references
browserenginekit
references
callkit
references
carplay
references
cloudkit
references
contacts-framework
references
core-bluetooth
references
core-data
core-motion
references
core-nfc
references
coreml
references
cryptokit
references
cryptotokenkit
references
debugging-instruments
device-integrity
references
dockkit
references
energykit
references
eventkit
references
financekit
references
focus-engine
gamekit
references
healthkit
references
homekit
references
ios-accessibility
ios-localization
ios-networking
ios-simulator
references
mapkit
metrickit
references
musickit
references
natural-language
references
paperkit
references
passkit
references
pdfkit
references
pencilkit
references
permissionkit
references
photokit
push-notifications
realitykit
references
relevancekit
references
scenekit
references
sensorkit
references
speech-recognition
spritekit
references
storekit
swift-api-design-guidelines
swift-architecture
swift-charts
references
swift-codable
swift-concurrency
swift-formatstyle
swift-language
swift-security
references
swift-testing
swiftdata
swiftlint
swiftui-animation
swiftui-gestures
references
swiftui-layout-components
swiftui-liquid-glass
references
swiftui-patterns
swiftui-performance
swiftui-uikit-interop
swiftui-webkit
tabletopkit
references
tipkit
references
vision-framework
weatherkit
references
widgetkit
references