{"id":28417,"library":"tree-sitter-swift","title":"tree-sitter-swift","description":"Swift grammar for tree-sitter, providing incremental parsing, syntax highlighting, and code analysis for the Swift programming language. Current version: 0.7.2. Released irregularly, with updates following Swift language evolution and tree-sitter releases.","status":"active","version":"0.7.2","language":"python","source_language":"en","source_url":"https://github.com/alex-pinkus/tree-sitter-swift","tags":["tree-sitter","swift","parser","grammar","synatx","highlighting"],"install":[{"cmd":"pip install tree-sitter-swift","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Required to load and use the grammar; tree-sitter-swift provides only the grammar definition.","package":"tree-sitter","optional":false}],"imports":[{"note":"The correct export is a function `language()`, not a class `Language`.","wrong":"from tree_sitter_swift import Language","symbol":"Language","correct":"from tree_sitter_swift import language"}],"quickstart":{"code":"import tree_sitter as ts\nfrom tree_sitter_swift import language\n\nparser = ts.Parser(language())\ntree = parser.parse(b\"let x = 42\")\nprint(tree.root_node.type)","lang":"python","description":"Create a parser with the Swift language and parse a simple Swift snippet."},"warnings":[{"fix":"Update tree-sitter to >=0.23.0: pip install 'tree-sitter>=0.23'","message":"In version 0.7.0, the grammar was updated to tree-sitter 0.23, introducing breaking changes in the tree-sitter API. Ensure you are using tree-sitter >= 0.23.0.","severity":"breaking","affected_versions":">=0.7.0, <0.8.0"},{"fix":"Replace `from tree_sitter_swift import Language` with `from tree_sitter_swift import language` and call `language()`.","message":"The import path from tree_sitter_swift import Language is deprecated. Use from tree_sitter_swift import language instead.","severity":"deprecated","affected_versions":">=0.5.0, <0.8.0"},{"fix":"Re-create the parser and load the grammar after deserialization instead of pickling the parser directly.","message":"Grammar functions may be pickled incorrectly if you try to serialize the parser object with the grammar loaded.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.7.2':26 'analysi':18 'code':17 'current':24 'evolut':34 'follow':31 'grammar':6,45 'highlight':15,47 'increment':12 'irregular':28 'languag':23,33 'pars':13 'parser':44 'program':22 'provid':11 'releas':27,39 'sitter':3,10,38,42 'swift':4,5,21,32,43 'synatx':46 'syntax':14 'tree':2,9,37,41 'tree-sitt':8,36,40 'tree-sitter-swift':1 'updat':30 'version':25","created_at":"2026-05-09T05:55:24.320072+00:00","updated_at":"2026-05-09T05:55:24.320072+00:00","problems":[{"fix":"Change import to: from tree_sitter_swift import language","cause":"Importing a non-existent attribute `Language`; the correct import is the function `language` without capital L.","error":"AttributeError: module 'tree_sitter_swift' has no attribute 'Language'"},{"fix":"Use the newer API: parser = ts.Parser(language())","cause":"Passing the language object directly to `Parser()` in older tree-sitter versions (<0.23) or using the wrong API pattern.","error":"TypeError: Parser() takes no arguments"},{"fix":"Ensure you have Rust installed to compile from source, or use a version that supports your platform: pip install 'tree-sitter-swift>=0.7'","cause":"Attempting to install a version of `tree-sitter-swift` that does not have a prebuilt wheel for the current platform or Python version.","error":"tree_sitter_swift does not provide bindings for version x.y.z"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/alex-pinkus/tree-sitter-swift","docs":null,"changelog":null,"pypi":"https://pypi.org/project/tree-sitter-swift/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}