{"library":"rubicon-objc","title":"Rubicon-ObjC","description":"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.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install rubicon-objc"],"cli":null},"imports":["from rubicon.objc import ObjCClass","from rubicon.objc import NSObject","from rubicon.objc import ObjCBlock","from rubicon.objc import RubiconEventLoop","from rubicon.objc import objc_id"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from rubicon.objc import ObjCClass, NSObject\nimport asyncio\n\n# Access an Objective-C class (e.g., NSURL from Foundation framework)\nNSURL = ObjCClass(\"NSURL\")\n\n# Create an instance using a static constructor method.\n# Objective-C methods with ':' are mapped to Python keyword arguments or replaced with '_' in method name.\n# E.g., Objective-C's +URLWithString: becomes .URLWithString_() or .URLWithString(url_string).\nbase_url = NSURL.URLWithString_(\"https://beeware.org/\")\nprint(f\"Base URL: {base_url}\")\n\n# Call another method with multiple arguments using keyword arguments\nfull_url = NSURL.URLWithString_relativeToURL_(\"contributing/\", relativeToURL=base_url)\nprint(f\"Full URL: {full_url}\")\n\n# Access Objective-C properties using Python attribute syntax\nprint(f\"Full URL scheme: {full_url.scheme}\")\n\n# --- Defining a new Objective-C class in Python ---\n# In interactive environments (like Pythonista) or when re-running code, \n# Objective-C class redefinition can cause errors. auto_rename avoids this.\nObjCClass.auto_rename = True # Set globally or pass auto_rename=True to ObjCClass() constructor\n\nclass MyPythonDelegate(NSObject):\n    # Initialize the Objective-C object. Must call super().init()\n    def init(self):\n        self = super().init()\n        if self:\n            print(\"MyPythonDelegate initialized!\")\n        return self\n\n    # Define an Objective-C method (e.g., a delegate callback)\n    # Argument types should generally be annotated for clarity and correctness.\n    def myDelegateMethod_withValue_(self, sender: 'id', value: int):\n        print(f\"Delegate method called by {sender} with value: {value}\")\n        return None # Objective-C methods often return `void` or `id` (None for Python)\n\n# Instantiate the Python-defined Objective-C class\ndelegate_instance = MyPythonDelegate.alloc().init()\n\n# Example of calling its method (simulating an Objective-C call)\ndelegate_instance.myDelegateMethod_withValue_(NSObject.alloc().init(), 42)\n","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"0.5.2","pypi_latest":"0.5.4","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":1.6,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"rubicon-objc","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"18.2M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"rubicon-objc","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"rubicon-objc","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"20.1M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"rubicon-objc","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":"21M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"rubicon-objc","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"12.0M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"rubicon-objc","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"rubicon-objc","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.7M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"rubicon-objc","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"rubicon-objc","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"17.7M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"rubicon-objc","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":"18M"}]}}