/swift:debuggingfrom swift
Use when Swift code misbehaves at runtime and its cause is unproven (failing or crashing test, trap, thrown error, hung task, data race, executor violation, leak), covering Swift sessions of the debugger server, test runners, error and failure stops, sanitizers, backtraces, and dSYMs
Ships in swift. 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.
Covers Swift executables, test bundles, and apps on macOS, debugged under the lldb-dap of xcode-select's Xcode. Use tool:debugging for the method, session answers, crash reports, and LLDB outside a session. Use swift:testing for test selection, plans, and result bundles.
[REFERENCES]:
xctraceFacts read before a session, in order:
xcrun lldb --no-lldbinit -b -o version prints an Apple Swift version line with the swiftlang build xcrun swift --version prints
xcode-select -s <Xcode> or DEVELOPER_DIR selects the Xcode that built the programswift build --build-tests, then swift build --show-bin-path names the folder holding <product> and <Target>.xctestxcodebuild -showBuildSettings -json reads BUILT_PRODUCTS_DIR and SWIFT_OPTIMIZATION_LEVEL, where -Onone keeps locals-showBuildSettings is empty, and the DerivedData folder whose WorkspacePath matches holds Build/Products/Debugxcodebuild -showBuildSettings -json -scheme <scheme> -configuration Debug -destination 'generic/platform=macOS' \
| jq -r '.[0].buildSettings | .BUILT_PRODUCTS_DIR, .SWIFT_OPTIMIZATION_LEVEL'
for f in ~/Library/Developer/Xcode/DerivedData/*/info.plist; do
echo "$(plutil -extract WorkspacePath raw -o - "$f") $(dirname "$f")"
done
One route per question:
| [INDEX] | [QUESTION] | [ROUTE] |
|---|---|---|
| [01] | Executable computes a wrong value or exits wrong | Program launch |
| [02] | XCTest case or Swift Testing test fails or crashes | Test runner launch |
| [03] | Error thrown, origin unknown | Filter swift_throw |
| [04] | Trap, fatalError, force unwrap, index out of range | Launch with no breakpoint |
| [05] | Race in unsafe code, memory error, off-main UI call | Sanitizer or checker launch |
| [06] | Crash in a shell or test run with no session | SWIFT_BACKTRACE |
| [07] | Installed app crashed, or a binary lacks debug info | Archived dSYM |
| [08] | Task hangs, actor stalls, executor violation, data race | references/concurrency.md |
| [09] | Memory grows or leaks | references/memory.md |
| [10] | Interface hangs, work is slow, timing decides | references/instruments.md |
Executables launch from the build folder of [01]:
<App>.app/Contents/MacOS/<App>, built Debuglldb-dap advertises exception filters swift_throw, swift_catch, objc_throw, objc_catch, cpp_throw, cpp_catchTest bundles launch with their breakpoints as executables do, program and args from the table:
| [INDEX] | [RUNS] | [PROGRAM] | [ARGS] |
|---|---|---|---|
| [01] | Every test of a bundle | $AGENT | $BUNDLE |
| [02] | One XCTest case | $AGENT | -XCTest <Class>/<method> $BUNDLE |
| [03] | Swift Testing by filter | $HELPER | --test-bundle-path $BINARY --filter <regex> $BINARY --testing-library swift-testing |
AGENT="$(xcode-select -p)/Platforms/MacOSX.platform/Developer/Library/Xcode/Agents/xctest"
HELPER="$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/libexec/swift/pm/swiftpm-testing-helper"
BUNDLE="<bin>/<Target>.xctest"
BINARY="$BUNDLE/Contents/MacOS/<Target>"
PLATFORM="$(xcrun --show-sdk-platform-path)"
args takes each word of a row as one string, with shell values expanded-XCTest selection runs no Swift Testing test--filter matches the ids swift test list prints (<Target>.<Suite>/<test>())$HELPER launches take env DYLD_FRAMEWORK_PATH $PLATFORM/Developer/Library/Frameworks and DYLD_LIBRARY_PATH $PLATFORM/Developer/usr/libDYLD_FRAMEWORK_PATH -> Fatal error: Failed to open test bundle naming XCTest.frameworkDYLD_LIBRARY_PATH -> Fatal error: Failed to open test bundle naming libXCTestSwiftSupport.dylibFailure stops take functions:
failureBreakpoint stops on each failed Swift Testing expectation and _XCTFailureBreakpoint on each XCTest failure, above the test's frame#expect, #require) bind inside its expansion and answer bound, moved to line <n>, the test's locals one frame downReads at a stop, in order:
evaluate compiles Swift in the frame and runs it: order.items.count * 10 answers result: 30, type Intrepl frame variable <name> prints the whole value from debug information and runs no coderepl po <expression> prints through CustomDebugStringConvertible or Mirror, running code in the processread scopes of the first frame with a path-Ononenext over an await can stop on later lines before its task suspends, with their locals unassignedawait line, possibly on another thread, and language swift task info through repl prints the id identifying a taskThrown errors stop through filter swift_throw:
swift_willThrow, frame 1 the throwing linethrows(E)) -> frames 0 and 1 in runtime code, frame 2 the throwing linecontinueswift_catch can stay unresolved. Set a breakpoint on the first executable line in catch and print its error binding through repl (po error)Traps (fatalError, precondition, force unwrap, index out of range, overflow) stop with no breakpoint:
stopped, breakpoint, Fatal error: <message>, or exception, EXC_BREAKPOINT for a trap with no messageSanitizer runs follow a reproduction without one, as instrumentation changes timing:
| [INDEX] | [QUESTION] | [SWIFTPM] | [XCODEBUILD] |
|---|---|---|---|
| [01] | Race past nonisolated(unsafe), locks, C, Objective-C | --sanitize=thread | -enableThreadSanitizer YES |
| [02] | Use after free or overflow in unsafe pointers or C | --sanitize=address | -enableAddressSanitizer YES |
| [03] | Undefined behavior of C-family code | --sanitize=undefined | -enableUndefinedBehaviorSanitizer YES |
stopped, breakpoint, Swift access race detected with report text in outputthreadSanitizerEnabled, addressSanitizer {"enabled": true}, or undefinedBehaviorSanitizerEnabled in defaultOptionsargument '-sanitize=thread' is not allowed with '-sanitize=address')$AGENT abort with Interceptors are not working -> set the printed DYLD_INSERT_LIBRARIES path in envxcrun drops DYLD_* variables, so a shell run starts $AGENT by its pathOff-main AppKit and UIKit calls stop through Main Thread Checker:
env DYLD_INSERT_LIBRARIES $(xcode-select -p)/usr/lib/libMainThreadChecker.dylib loads the checker into a launch<Class>.<method> must be used from main thread only, the first program frame under checker frames holding the callxcodebuild test runners load the checker unless plan option mainThreadCheckerEnabled is false, and its report fails no testSwift's runtime prints a crash of a process with no session attached:
SWIFT_BACKTRACE=enable=yes,interactive=no prints the crashed thread with file and line, format=json as one JSON objectenable=tty prints only the Fatal error line without a terminal, and traps exit with status 133xcodebuild starts test runners without shell variables, and TEST_RUNNER_SWIFT_BACKTRACE=<value> reaches each runner as SWIFT_BACKTRACEInstalled apps come from an archive, which strips each binary and leaves build object files behind, so file and line come from the archive's dSYM:
xcrun dwarfdump --uuid <App>.app/Contents/MacOS/<App> <archive>.xcarchive/dSYMs/<App>.app.dSYM prints equal UUIDs per architecturetool:debugging symbolication with that dSYMpendingrepl target symbols add <dSYM> adds the dSYM, and pending breakpoints bindArchived and exported apps carry no get-task-allow, so sessions take a Debug build of the same source.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub bsamiee/rasm --plugin swift3 skills in this plugin
/codingUse when writing or reviewing Swift, covering functional design with typed throws, value types, and structured concurrency/testingUse when writing, running, or debugging Swift tests, covering Swift Testing traits, expectations, arguments, exit tests, attachments, generated inputs, privacy grants, XCTest performance metrics, and CIOther plugins' skills for the same job