Rubicon-ObjC is a robust bridge between the Python and Objective-C runtime environments, enabling Python code to instantiate, invoke methods on, and subclass Objective-C classes. It's a fundamental component of the BeeWare suite for building native applications with Python. The library is actively maintained, with its current version being 0.5.3, and follows a regular release cadence to support new Python versions and fix bugs.
pip install rubicon-objcVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to access existing Objective-C classes like `NSURL`, create instances, call methods using Pythonic syntax (handling Objective-C selectors with colons), and access properties. It also shows how to define a new Objective-C class in Python by subclassing `NSObject`, including important considerations for interactive development environments regarding class redefinition.
Upgrade your Python environment to 3.10 or higher, or pin `rubicon-objc<0.5.3`.
Instead of `asyncio.set_event_loop_policy(EventLoopPolicy())` and `asyncio.new_event_loop()`, directly instantiate and use `loop = RubiconEventLoop()` for your event loop. This change is backward compatible for older Python versions too.
Familiarize yourself with `rubicon-objc`'s selector translation rules. When in doubt, check the method signature in Objective-C documentation and experiment with both `_` and keyword argument styles.
Add `ObjCClass.auto_rename = True` at the top of your script or pass `auto_rename=True` as a keyword argument when defining Objective-C classes in Python.
Upgrade to `rubicon-objc` v0.5.0 or newer to benefit from automatic memory management. If on older versions, ensure correct manual retain/release calls, especially for objects returned by methods starting with 'alloc', 'new', 'copy', or 'mutableCopy'.
For explicit conversion of Objective-C return values to their Python equivalents, use `rubicon.objc.api.py_from_ns(obj)`.
No dependency data recorded yet.