$ show beeware/rubicon-objc
Rubicon-ObjC is a bridge library enabling Python to interact with Objective-C runtime and frameworks. It allows instantiation and invocation of Objective-C objects from Python, subclassing Objective-C classes in Python, and automatic conversion between Python and Objective-C data types. The library is part of the BeeWare suite for cross-platform Python GUI development, targeting iOS/macOS platforms. Architecture centers around modular submodules: api (high-level decorators and wrappers), runtime (low-level Objective-C interactions), types (data conversion), collections (Foundation collection wrappers), and eventloop (asyncio integration). Key features include bidirectional type conversion, decorator-based exposure of Python to Objective-C, block handling, and memory management automation. The library is used in production iOS apps (e.g., Travel Tips) and serves as a dependency for other BeeWare projects like Toga.
The LLM identified 2 files worth highlighting for reuse:
Implements bidirectional conversion between Python and Objective-C objects via ns_from_py() and py_from_ns() functions. Handles recursive conversion of scalars, collections (lists/dicts to NSArray/NSDictionary), and custom objects. Isolated dependency only on runtime for class lookup, making it extractable for similar language bridging tasks. Demonstrates sophisticated handling of memory management and type safety during conversion.
Provides decorators (@objc_method, @objc_classmethod, @objc_property) that expose Python callables to Objective-C runtime. Automates method signature matching, selector generation, and property getter/setter synthesis. Self-contained with minimal dependencies (primarily runtime functions). Shows advanced metaprogramming techniques for runtime method injection and signature handling, enabling natural Objective-C class definition in Python.