{"id":28414,"library":"tree-sitter-objc","title":"tree-sitter-objc","description":"Objective-C grammar for tree-sitter (v3.0.2). Parses Objective-C and Objective-C++ source code into a concrete syntax tree. Requires Python >=3.9.","status":"active","version":"3.0.2","language":"python","source_language":"en","source_url":"https://github.com/tree-sitter-grammars/tree-sitter-objc","tags":["tree-sitter","grammar","objective-c","parser"],"install":[{"cmd":"pip install tree-sitter-objc","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Runtime dependency for language bindings","package":"tree-sitter","optional":false}],"imports":[{"note":"The correct import is the function 'language', not a class 'Language' directly.","wrong":"from tree_sitter_objc import Language","symbol":"Language","correct":"from tree_sitter_objc import language"}],"quickstart":{"code":"from tree_sitter import Language, Parser\n\n# Load the Objective-C grammar (v3.0.2)\nObjCLanguage = Language('tree_sitter_objc', 'objc')\n\nparser = Parser()\nparser.set_language(ObjCLanguage)\n\n# Parse a simple Objective-C snippet\nsource = b\"\"\"\n#import <Foundation/Foundation.h>\n\n@interface MyClass : NSObject\n- (void)sayHello;\n@end\n\"\"\"\n\ntree = parser.parse(source)\nprint(tree.root_node.sexp())","lang":"python","description":"Minimal example: load the grammar, parse ObjC code, and print the syntax tree."},"warnings":[{"fix":"Use 'from tree_sitter_objc import language' and pass it to Language() or use Language('tree_sitter_objc', 'objc').","message":"v3.0.0+ switched from a direct 'Language' class to a 'language()' function. The grammar is loaded via tree-sitter's Language constructor using the module name.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"When using Language('tree_sitter_objc', 'objc'), the second argument is the language name, not the module name.","message":"The grammar module name is 'tree_sitter_objc' but the language name is 'objc'. Do not confuse these.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade Python to 3.9 or later.","message":"Python 3.8 and earlier are not supported. Requires Python >=3.9.","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use 'from tree_sitter_objc import language' or 'from tree_sitter import Language'.","cause":"Incorrect import: trying to import a class 'Language' that does not exist.","error":"ImportError: cannot import name 'Language' from 'tree_sitter_objc'"},{"fix":"Install the latest version: pip install --upgrade tree-sitter-objc.","cause":"Outdated version of tree-sitter-objc (before v3.0.0) or the grammar wasn't properly installed.","error":"AttributeError: module 'tree_sitter_objc' has no attribute 'language'"},{"fix":"Use 'objc' (not 'objective-c' or 'objc++') for the language name.","cause":"The language name passed to Language() doesn't match the registered grammar.","error":"ValueError: Unknown language 'objc'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}