To find why an async task never returns, profile the app with Xcode's Swift Concurrency template in Instruments (Product → Profile), pin the stuck task, and read its Narrative View. The usual shapes are an async function that never finishes, a frozen @MainActor view, or throughput that collapses under load. The fix is rarely a guess at the call site. It is a few minutes with the Swift Tasks and Swift Actors instruments, then one targeted code change.
How do I capture a Swift Concurrency trace?
Open the project in Xcode on the remote Mac, choose Product → Profile and pick the Swift Concurrency template. Run the scenario that triggers the stall. Instruments shows the Swift Tasks, Swift Actors and task forest tracks side by side. Right-click a task in the timeline and pin it to open the Narrative View, which explains why that task is Running, Enqueued or Waiting. Apple walks through the template in the WWDC22 session Visualize and optimize Swift Concurrency.
What if the remote desktop is too slow to profile?
Record the trace headlessly over SSH, then download the .trace bundle and open it in Instruments on your local Mac:
# On the remote Mac. Order matters: --launch is last and ends the record command.
xcrun xctrace record \
--template 'Swift Concurrency' \
--time-limit 30s \
--output ~/Desktop/concurrency.trace \
--launch -- /path/to/YourApp.app/Contents/MacOS/YourApp
All task and actor data is embedded in the trace file, so you do not need to stay connected to analyze it.
Which check explains a stuck task?
Work through this worksheet in order. Each row maps to a place in Instruments or a specific code change.
| Check | What to look for | Tool or change |
|---|---|---|
| Task Waiting indefinitely | A withCheckedContinuation whose closure returns without calling resume | Swift Tasks → Narrative View; Xcode runtime warning "leaked continuation" |
| Main actor blocked | A @MainActor method doing sync I/O or long compute | Swift Tasks → State track on the main thread; move work to an actor or Task.detached |
| Actor contention | Many tasks stacked Enqueued behind one long method on the same actor | Swift Actors instrument; mark pure functions nonisolated |
| Cooperative pool starvation | Running task count stays pinned at core count with no progress | Running Tasks graph; find blocking syscalls inside async code |
| Wrong isolation at runtime | Unexpected hops or data races | Add MainActor.assertIsolated() at the suspect site; enable SWIFT_STRICT_CONCURRENCY=complete and fix the warnings |
| Priority inversion | High-priority task waiting on a low-priority actor | Task forest view; raise the actor's effective priority or split its state |
One pass through the table usually points at a single change: move compute off the main actor, mark a helper nonisolated, or resume a continuation on the error path. Re-run the same trace to confirm the stall is gone instead of timing a flaky scenario by wall clock.
Which editor should I use for Swift on a remote Mac?
Xcode on the remote Mac, for concurrency debugging, because Instruments and its Swift Tasks and Swift Actors tracks live there. JetBrains Fleet is no longer a safe recommendation: downloads were retired on 22 December 2025 and existing installs have no guaranteed future updates. JetBrains AppCode was retired earlier. Three paths work for Swift today:
- Xcode directly on the remote Mac, over remote desktop. This is the only path that gives you Instruments, the simulator and the project templates in one place.
- VS Code or Cursor with
sourcekit-lsp, over SSH remote editing, if you mostly want code intelligence and run builds from a terminal. - Your existing JetBrains IDE for non-Swift parts of the codebase, with Xcode on the remote Mac reserved for build, sign and profile.
How do I keep the evidence useful afterwards?
Attach the captured .trace to the ticket that reported the stall, so the next engineer starts with evidence rather than a reproduction script. If you run CI on the same Mac, keep signing secrets in your CI service's secret manager rather than exporting them into shell files on the host, and keep the Xcode version pinned to the one used when the trace was captured.
Where should a Swift Concurrency Instruments session run?
The Apple Silicon Mac VM ($39 a month, $6 a day, 4GB RAM) runs current Xcode and is the natural seat for an interactive Instruments session in the browser desktop. If your project builds on Xcode 26.3 or earlier, the Intel Mac VM ($25 a month, $2 a day) also has the Swift Concurrency template. Check the macOS version shown before purchase against Apple's Xcode table. VM vCPUs are shared, so compare traces taken under the same load.
Related: Upload dSYMs to App Store Connect from a Remote Mac · Debug Core Data Issues on a Rented Remote Mac · GitHub Actions Self-Hosted Runner on Mac