Release History

0.4.2 (2021-11-14)


  • Added autoreleasepool context manager to mimic Objective-C @autoreleasepool blocks. (#213)

  • Allow storing Python objects in Objective-C properties declared with @objc_property. (#214)

  • Added support for Python 3.10. (#218)


  • Raise TypeError when trying to declare a weak property of a non-object type. (#215)

  • Corrected handling of methods when a class overrides a method defined in a grandparent. (#216)

0.4.1 (2021-07-25)


  • Added official support for Python 3.9. (#193)

  • Added official support for macOS 11 (Big Sur). (#195)

  • Autorelease Objective-C instances when the corresponding Python instance is destroyed. (#200)

  • Improved memory management when a Python instance is assigned to a new ObjCInstance attribute. (#209)

  • Added support to declare weak properties on custom Objective-C classes. (#210)


  • Fixed incorrect behavior of Block when trying to create a block with no arguments and using explicit types. This previously caused an incorrect exception about missing argument types; now a no-arg block is created as expected. (#153)

  • Fixed handling of type annotations when passing a bound Python method into Block. (#153)

  • A cooperative entry point for starting event loop has been added. This corrects a problem seen when using Python 3.8 on iOS. (#182)

  • Improved performance of Objective-C method calls and ObjCInstance creation in many cases. (#183)

  • Fix calling of signal handlers added to the asyncio loop with CFRunLoop integration. (#202)

  • Allow restarting a stopped event loop. (#205)

Deprecations and Removals

  • Removed automatic conversion of Objective-C numbers (NSNumber and NSDecimalNumber) to Python numbers when received from Objective-C (i.e. returned from an Objective-C method or property or passed into an Objective-C method implemented in Python). This automatic conversion significantly slowed down every Objective-C method call that returns an object, even though the conversion doesn’t apply to most method calls. If you have code that receives an Objective-C number and needs to use it as a Python number, please convert it explicitly using py_from_ns() or an appropriate Objective-C method.

    As a side effect, NSNumber and NSDecimalNumber values stored in Objective-C collections (NSArray, NSDictionary) are also no longer automatically unwrapped when retrieved from the collection, even when using Python syntax to access the collection. For example, if arr is a NSArray of integer NSNumber, arr[0] now returns an Objective-C NSNumber and not a Python int as before. If you need the contents of an Objective-C collection as Python values, you can use py_from_ns() to convert either single values (e. g. py_from_ns(arr[0])) or the entire collection (e. g. py_from_ns(arr)). (#183)

  • Removed macOS 10.12 through 10.14 from our automatic test matrix, due to pricing changes in one of our CI services (Travis CI). OS X 10.11 is still included in the test matrix for now, but will probably be removed relatively soon. Automatic tests on macOS 10.15 and 11.0 are unaffected as they run on a different CI service (GitHub Actions).

    Rubicon will continue to support macOS 10.14 and earlier on a best-effort basis, even though compatibility is no longer tested automatically. If you encounter any bugs or other problems with Rubicon on these older macOS versions, please report them! (#197)


0.4.0 (2020-07-04)


  • Added macOS 10.15 (Catalina) to the test matrix. (#145)

  • Added PEP 517 and PEP 518 build system metadata to pyproject.toml. (#156)

  • Added official support for Python 3.8. (#162)

  • Added a varargs keyword argument to send_message() to allow calling variadic methods more safely. (#174)

  • Changed ObjCMethod to call methods using send_message() instead of calling IMPs directly. This is mainly an internal change and should not affect most existing code, although it may improve compatibility with Objective-C code that makes heavy use of runtime reflection and method manipulation (such as swizzling). (#177)


  • Fixed Objective-C method calls in “flat” syntax accepting more arguments than the method has. The extra arguments were previously silently ignored. An exception is now raised if too many arguments are passed. (#123)

  • Fixed ObjCInstance.__str__ throwing an exception if the object’s Objective-C description is nil. (#125)

  • Corrected a slow memory leak caused every time an asyncio timed event handler triggered. (#146)

  • Fixed various minor issues in the build and packaging metadata. (#156)

  • Removed unit test that attempted to pass a struct with bit fields into a C function by value. Although this has worked in the past on x86 and x86_64, ctypes never officially supported this, and started generating an error in Python 3.7.6 and 3.8.1 (see bpo-39295). (#157)

  • Corrected the invocation of NSApplication.terminate() when the CocoaLifecycle is ended. (#170)

  • Fixed send_message() not accepting SEL objects for the selector parameter. The documentation stated that this is allowed, but actually doing so caused a type error. (#177)

Improved Documentation

Deprecations and Removals

  • Removed the i386 architecture from the test matrix. It is still supported on a best-effort basis, but compatibility is not tested automatically. (#139)

  • Tightened the API of send_message(), removing some previously allowed shortcuts and features that were rarely used, or likely to be used by accident in an unsafe way.


    In most cases, Rubicon’s high-level method call syntax provided by ObjCInstance can be used instead of send_message(). This syntax is almost always more convenient to use, more readable and less error-prone. send_message() should only be used in cases not supported by the high-level syntax.

  • Disallowed passing class names as str/bytes as the receiver argument of send_message(). If you need to send a message to a class object (i. e. call a class method), use ObjCClass or get_class() to look up the class, and pass the resulting ObjCClass or Class object as the receiver.

  • Disallowed passing c_void_p objects as the receiver argument of send_message(). The receiver argument now has to be of type objc_id, or one of its subclasses (such as Class), or one of its high-level equivalents (such as ObjCInstance). All Objective-C objects returned by Rubicon’s high-level and low-level APIs have one of these types. If you need to send a message to an object pointer stored as c_void_p, cast() it to objc_id first.

  • Removed default values for send_message()’s restype and argtypes keyword arguments. Every send_message() call now needs to have its return and argument types set explicitly. This ensures that all arguments and the return value are converted correctly between (Objective-)C and Python.

  • Disallowed passing more argument values than there are argument types in argtypes. This was previously allowed to support calling variadic methods - any arguments beyond the types set in argtypes would be passed as varargs. However, this feature was easy to misuse by accident, as it allowed passing extra arguments to any method, even though most Objective-C methods are not variadic. Extra arguments passed this way were silently ignored without causing an error or a crash.

    To prevent accidentally passing too many arguments like this, the number of arguments now has to exactly match the number of argtypes. Variadic methods can still be called, but the varargs now need to be passed as a list into the separate varargs keyword arugment. (#174)

  • Removed the rubicon.objc.core_foundation module. This was an internal module with few remaining contents and should not have any external uses. If you need to call Core Foundation functions in your code, please load the framework yourself using load_library('CoreFoundation') and define the types and functions that you need. (#175)

  • Removed the ObjCMethod class from the public API, as there was no good way to use it from external code. (#177)



  • Added a workaround for bpo-36880, which caused a “deallocating None” crash when returning structs from methods very often.

  • Added macOS High Sierra (10.13) and macOS Mojave (10.14) to the test matrix.

  • Renamed the rubicon.objc.async module to rubicon.objc.eventloop to avoid conflicts with the Python 3.6 async keyword.

  • Removed support for Python 3.4.

  • Removed OS X Yosemite (10.10) from the test matrix. This version is (and older ones are) still supported on a best-effort basis, but compatibility is not tested automatically.


  • Added Pythonic operators and methods on NSString objects, similar to those for NSArray and NSDictionary.

  • Removed automatic conversion of NSString objects to str when returned from Objective-C methods. This feature made it difficult to call Objective-C methods on NSString objects, because there was no easy way to prevent the automatic conversion.

    In most cases, this change will not affect existing code, because NSString objects now support operations similar to str. If an actual str object is required, the NSString object can be wrapped in a str call to convert it.

  • Added support for objc_propertys with non-object types.

  • Added public get_ivar and set_ivar functions for manipulating ivars.

  • Changed the implementation of objc_property to use ivars instead of Python attributes for storage. This fixes name conflicts in some situations.

  • Added the load_library() function for loading CDLLs by their name instead of their full path.

  • Split the high-level Rubicon API (ObjCInstance, ObjCClass, etc.) out of rubicon.objc.runtime into a separate rubicon.objc.api module. The runtime module now only contains low-level runtime interfaces like libobjc.

    This is mostly an internal change, existing code will not be affected unless it imports names directly from rubicon.objc.runtime.

  • Moved c_ptrdiff_t from rubicon.objc.runtime to rubicon.objc.types.

  • Removed some rarely used names (IMP, Class, Ivar, Method, get_ivar(), objc_id, objc_property_t, set_ivar()) from the main rubicon.objc namespace.

    If needed, these names can be imported explicitly from the rubicon.objc.runtime module.

  • Fixed objc_property setters on non-macOS platforms. (cculianu)

  • Fixed various bugs in the collection ObjCInstance subclasses:

  • Fixed getting/setting/deleting items or slices with indices lower than -len(obj). Previously this crashed Python, now an IndexError is raised.

  • Fixed slices with step size 0. Previously they were ignored and 1 was incorrectly used as the step size, now an IndexError is raised.

  • Fixed equality checks between Objective-C arrays/dictionaries and non-sequence/mapping objects. Previously this incorrectly raised a TypeError, now it returns False.

  • Fixed equality checks between Objective-C arrays and sequences of different lengths. Previously this incorrectly returned True if the shorter sequence was a prefix of the longer one, now False is returned.

  • Fixed calling popitem on an empty Objective-C dictionary. Previously this crashed Python, now a KeyError is raised.

  • Fixed calling update with both a mapping and keyword arguments on an Objective-C dictionary. Previously the kwargs were incorrectly ignored if a mapping was given, now both are respected.

  • Fixed calling methods using kwarg syntax if a superclass and subclass define methods with the same prefix, but different names. For example, if a superclass had a method initWithFoo:bar: and the subclass initWithFoo:spam:, the former could not be called on instances of the subclass.

  • Fixed the internal ctypes_patch module so it no longer depends on a non-public CPython function.


  • Rewrote almost all Core Foundation-based functions to use Foundation instead.

    • The functions from_value and NSDecimalNumber.from_decimal have been removed and replaced by ns_from_py.

    • The function at is now an alias for ns_from_py.

    • The function is_str has been removed. is_str(obj) calls should be replaced with isinstance(obj, NSString).

    • The functions to_list, to_number, to_set, to_str, and to_value have been removed and replaced by py_from_ns.

  • Fixed declare_property not applying to subclasses of the class it was called on.

  • Fixed repr of ObjCBoundMethod when the wrapped method is not an ObjCMethod.

  • Fixed the encodings of NSPoint, NSSize, and NSRect on 32-bit systems.

  • Renamed the async support package to eventloop to avoid a Python 3.5+ keyword clash.


  • Improved handling of boolean types.

  • Added support for using primitives as object values (e.g, as the key/value in an NSDictonary).

  • Added support for passing Python lists as Objective-C NSArray arguments, and Python dicts as Objective-C NSDictionary arguments.

  • Corrected support to storing strings and other objects as properties on Python-defined Objective-C classes.

  • Added support for creating Objective-C blocks from Python callables. (ojii)

  • Added support for returning compound values (structures and unions) from Objective-C methods defined in Python.

  • Added support for creating, extending and conforming to Objective-C protocols.

  • Added an objc_const convenience function to look up global Objective-C object constants in a DLL.

  • Added support for registering custom ObjCInstance subclasses to be used to represent Objective-C objects of specific classes.

  • Added support for integrating NSApplication and UIApplication event loops with Python’s asyncio event loop.


  • Added support for using native Python sequence/mapping syntax with NSArray and NSDictionary. (jeamland)

  • Added support for calling Objective-C blocks in Python. (ojii)

  • Added functions for declaring custom conversions between Objective-C type encodings and ctypes types.

  • Added functions for splitting and decoding Objective-C method signature encodings.

  • Added automatic conversion of Python sequences to C arrays or structures in method arguments.

  • Extended the Objective-C type encoding decoder to support block types, bit fields (in structures), typed object pointers, and arbitrary qualifiers. If unknown pointer, array, struct or union types are encountered, they are created and registered on the fly.

  • Changed the PyObjectEncoding to match the real definition of PyObject *.

  • Fixed the declaration of unichar (was previously c_wchar, is now c_ushort).

  • Removed the get_selector function. Use the SEL constructor instead.

  • Removed some runtime function declarations that are deprecated or unlikely to be useful.

  • Removed the encoding constants. Use encoding_for_ctype to get the encoding of a type.


  • (#40) Added the ability to explicitly declare no-attribute methods as properties. This is to enable a workaround when Apple introduces readonly properties as a way to access these methods.


  • Added a more compact syntax for calling Objective-C methods, using Python keyword arguments. (The old syntax is still fully supported and will not be removed; certain method names even require the old syntax.)

  • Added a superclass property to ObjCClass.


  • Added official support for Python 3.6.

  • Added keyword arguments to disable argument and/or return value conversion when calling an Objective-C method.

  • Added support for (NS/UI) EdgeInsets structs. (Longhanks)

  • Improved str of Objective-C classes and objects to return the debugDescription, or for NSStrings, the string value.

  • Changed ObjCClass to extend ObjCInstance (in addition to type), and added an ObjCMetaClass class to represent metaclasses.

  • Fixed some issues on non-x86_64 architectures (i386, ARM32, ARM64).

  • Fixed example code in README. (Dayof)

  • Removed the last of the Python 2 compatibility code.


  • Added objc_property function for adding properties to custom Objective-C subclasses. (Longhanks)


  • Removed most Python 2 compatibility code.


  • Dropped support for Python 3.3.

  • Added conversion of Python enum.Enum objects to their underlying values when passed to an Objective-C method.

  • Added syntax highlighting to example code in README. (stsievert)

  • Fixed the shebang line. (uranusjr)


  • Fixed setting of ObjCClass/ObjCInstance attributes that are not Objective-C properties.


  • First beta release.

  • Dropped support for Python 2. Python 3 is now required, the minimum tested version is Python 3.3.

  • Added error detection when attempting to create an Objective-C class with a name that is already in use.

  • Added automatic conversion between Python decimal.Decimal and Objective-C NSDecimal in method arguments and return values.

  • Added PyPy to the list of test platforms.

  • When subclassing Objective-C classes, the return and argument types of methods are now specified using Python type annotation syntax and ctypes types.

  • Improved property support.


  • Fixed some issues on ARM64 (iOS 64-bit).


  • Fixed NSString conversion in a few situations.

  • Fixed some issues on iOS and 32-bit platforms.


  • Objective-C classes can now be subclassed using Python class syntax, by using an ObjCClass as the superclass.

  • Removed ObjCSubclass, which is made obsolete by the new subclassing syntax.


  • Initial alpha release.

  • Objective-C classes and instances can be accessed via ObjCClass and ObjCInstance.

  • Methods can be called on classes and instances with Python method call syntax.

  • Properties can be read and written with Python attribute syntax.

  • Method return and argument types are read automatically from the method type encoding.

  • A small number of commonly used structs are supported as return and argument types.

  • Python strings are automatically converted to and from NSString when passed to or returned from a method.

  • Subclasses of Objective-C classes can be created with ObjCSubclass.