🍏 Compatibility layer with Apple Objective-C runtime functions
Branch: release
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



🍏 Compatibility layer with Apple Objective-C runtime functions

This library maps Apple runtime functions to their mulle-objc counterparts. This makes porting of existing programs that use Apple runtime functions easier. If you can get by with the limited set of functions, these functions are preferable to use over their mulle-objc counterparts for the sake of portability and familiarity.

Build Status Release Version
Build Status Mulle kybernetiK tag Build Status

Mental model

This library

  • does not include any other runtime than mulle-objc-runtime.
  • does not define any functionality that is not part of the Apple runtime
  • does not implement everything that's in the Apple runtime


  • This library hasn't been scrutinized for thread-safety.
  • Some functionality is missing that mulle-objc does not support. E.g. "weak variables".
  • Message sending via objc_msgSend uses the mulle-objc MetaABI and therefore is only compatible in the case, where there is only one pointer sized parameter and a pointer sized return value.
  • The library must be compiled with mulle-clang (since the multiverse changes)

Register unknown selectors before using class_addMethod and class_replaceMethod

The use of @selector( undefinedByAll) does not give the runtime enough information to produce proper methods. Therefore you must sel_registerName before usage.

Dealing with objc_msgSend

It is fairly conventional to write various objc_msgSend0, objc_msgSend1, objc_msgSend2 functions that deal with varying parameters and return values. These functions are not part of the library. objc_msgSend is defined though.

Use the mulle-objc MetaABI convention to pass parameters and inspect return values.

Dealing with objc_msgSend_stret

Use the mulle-objc MetaABI and objc_msgSend directly.

Protocols in mulle-objc are almost only syntax

This means:

  • the runtime only knows about protocols that are adopted by a class
  • a protocol in mulle-objc is mainly a hash value (like a selector)
  • the information about methods and properties of a protocol are gone, the introspection candidate is the class
  • you can not message protocols

There is no enveloping NSAutoreleasePool around +load in mulle-objc

If you create ephemeral instances in your +load method, you should wrap the code yourself inside an NSAutoreleasePool.

You can't go as crazy in +initialize

  • do not call [super initialize], which is pointless anyway.
  • do not message subclasses

How to build

This is a mulle-sde project.

It has it's own virtual environment, that will be automatically setup for you once you enter it with:

mulle-sde mulle-objc-compat

Now you can let mulle-sde fetch the required dependencies and build the project for you:

mulle-sde craft