Skip to content
libffi for the iPhone, including source code for simulator and device
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README.markdown Readme update
ffi-iphone.c Initial commit
ffi-iphone.h Initial commit
ffi-iphonesimulator.c Initial commit
ffi-iphonesimulator.h Initial commit
ffi_common.h Initial commit
fficonfig.h Initial commit
ffitarget-iphonesimulator.h Initial commit
ffitarget.h Initial commit
iphone-sysv.S Initial commit
prep_cif.c Initial commit
types.c Initial commit


libffi for the iPhone

libffi allows calling any C-function or ObjC method at runtime.

libffi-iphone is a stripped down version of libffi, tailored just for the iPhone. libffi-iphone includes source code for both the iPhone simulator and the iPhone itself.

Calling functions

Works just like libffi.

Creating ffi closures, new functions created and called at runtime

ffi closures don't work on the iPhone, as mprotect is disabled.

You can however retarget existing functions if you have a function pool. See Tim Burks' post about Nu's method pool, see JSCocoa's Burks Pool for another implementation.

To retarget an ObjC pool method, use the method's hidden _cmd argument (the current selector) and [self class]. This will tell you which method of which class is being called.


libffi-iphone uses libffi's license.


Problems, questions
Patrick Geiller

Something went wrong with that request. Please try again.