Choose Swift Language Tooling
Route Swift tooling by the information the task needs. Resolve toolchain ownership before interpreting output.
Workflow
- Inspect repository guidance,
Package.swift, Xcode project markers, build configuration, generated sources, and existing tooling dependencies. - Resolve the active toolchain without changing it:
- record
command -v swift,command -v swiftc, andswift --version - record
swiftly use --print-locationwhen Swiftly is installed - record
xcode-select -p,xcrun --find swiftc, andxcrun swiftc --versionon macOS - label each command and artifact as
Swiftly,Xcode, or another explicitly named toolchain
- record
- Choose one primary information model:
- source-accurate syntax and rewriting:
swift-syntax-tooling-workflow - compilation, diagnostics, AST, SIL, IR, modules, or driver jobs:
swift-compiler-inspection-workflow - types, USRs, documentation, occurrences, or symbol relationships:
swift-semantic-indexing-workflow - editor protocol, completion, navigation, refactoring, or language-service diagnosis:
sourcekit-lsp-workflow
- source-accurate syntax and rewriting:
- Resolve the project model:
- SwiftPM package
- Xcode project or workspace
- compilation database
- build server
- loose source file with explicit compiler arguments
- State why the selected surface answers the question and why the nearest alternative does not.
- Hand build, test, package-plugin, macro-package, signing, simulator, or device execution to the owning Apple Dev or server-side workflow.
Toolchain Contract
- Treat Swiftly and Xcode as separate first-class Swift toolchain owners.
- Use Swiftly-resolved tools for cross-platform Swift.org packages, CLI work, explicit
.swift-versionselection, and toolchain-version matrices unless repository guidance selects Xcode. - Use
xcrun-resolved tools when the task depends on an Apple SDK, selected Xcode, Xcode build settings, or Xcode-bundled SourceKit behavior. - Recognize that
swiftly use xcodemakes Swiftly proxy the currently selected Xcode toolchain; still record both the Swiftly selection andxcode-selectresult. - Do not mix a compiler from one toolchain with
sourcekitd, SourceKit-LSP, SDKs, plugins, or SwiftSyntax libraries from another and call the result valid. - Do not change
swiftly use,.swift-version,xcode-select, Xcode settings, orDEVELOPER_DIRmerely to inspect state.
Output
Return:
Toolchain ownership: Swiftly, Xcode, or another named owner for every selected binary.Information model: syntax, compiler artifact, semantic query, index, or LSP.Project model: SwiftPM, Xcode, compilation database, build server, or loose file.Selected workflow: one primary skill and any required handoff.Evidence: versions, resolved paths, build settings, and freshness of generated modules or indexes.
Guardrails
- Do not use SwiftSyntax to claim inferred types or project-wide references.
- Do not parse unstable compiler dumps when a supported library or protocol answers the question.
- Do not use raw SourceKit when LSP or SourceKitten already supplies the required contract with acceptable fidelity.
- Do not treat SourceKitten as a replacement for SwiftSyntax, SourceKit-LSP, or the compiler.
- Do not diagnose semantic or LSP failures before checking compiler arguments and build-state freshness.
Read references/tool-selection-matrix.md for the detailed routing matrix and stability classes.