--- id: tree-sitter-swift version: "0.7.3" license: MIT license_treatment: permissive maintenance: active --- # tree-sitter-swift — Swift grammar for tree-sitter License: permissive · Maintenance: active · Downloads: 1.9M/mo ## What it is and what it does tree-sitter-swift is a language grammar binding that plugs into the tree-sitter incremental parsing framework to parse Swift source code. It generates a syntax tree representation of Swift programs, which can be used for code analysis, transformation, linting, or IDE features. The package provides precompiled wheels for multiple platforms, eliminating the need to build the grammar locally in most cases. The grammar is maintained actively and designed to work with tree-sitter's core parser engine. It can be used from Python, Rust, JavaScript/Node.js, or WebAssembly environments depending on which tree-sitter binding you pair it with. The package itself contains only the language definition; you supply the tree-sitter parser library separately to actually parse code. Use it for: - Build a Swift linter or code quality checker that traverses the syntax tree to detect style violations. - Implement IDE features like syntax highlighting, code completion, or go-to-definition by querying the parse tree. - Analyze Swift codebases to extract metrics, find unused code, or refactor patterns across multiple files. - Create a Swift-to-other-language transpiler or code generator that walks the syntax tree and emits different output. - Develop a documentation generator that parses Swift source to extract and format API signatures and comments. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides a tree-sitter grammar for parsing Swift source code, enabling incremental syntax analysis and abstract syntax tree generation. Yes, if you need to parse Swift code programmatically. The package is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and provides prebuilt wheels for common platforms. The main caveat is that tree-sitter itself must be available in your environment; verify that dependency is clear before installing. ## Install pip install tree-sitter-swift uv add tree-sitter-swift poetry add tree-sitter-swift ## Installing tree-sitter-swift Before you install: Medium install friction due to compiled wheels; prebuilt binaries available for common platforms (macOS x86_64/arm64, Linux x86_64/aarch64, Windows x86_64/arm64, musl). Package is actively maintained with recent releases and no known vulnerabilities. License in practice: MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute the package provided you include the license notice. Quickstart: pip install tree-sitter-swift import tree_sitter_swift language = tree_sitter_swift.language() Python 3.8 or later required; tree-sitter parser library must be available separately in your environment. Verify before relying: - Whether tree-sitter is automatically installed as a transitive dependency or must be installed separately. - Performance characteristics when parsing large Swift codebases or in incremental update scenarios. - Completeness of Swift language coverage across recent Swift versions and all language constructs. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: medium - Maintenance: active - Downloads: 1.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags swift parser tree-sitter, swift syntax tree parsing, incremental swift code analysis, swift grammar parser, tree-sitter swift language, swift ast generation, swift code parsing library, parsing, swift, syntax-analysis [View on SkillFed](https://skillfed.io/packages/tree-sitter-swift) · [View on PyPI](https://pypi.org/project/tree-sitter-swift/)