Dev:Clang-logos

Clang-logos is an Objective-C extension for hooking class methods at runtime via MobileSubstrate. It is developed by Evan Swick.

Overview
Clang-logos builds upon the original Logos preprocessor, but brings quite a few features that the original Logos preprocessor isn't capable of. This is because clang-logos, as indicated by its name, is part of Clang, giving it the full power of the compiler. It isn't a preprocessor; hook code is compiled directly from Objective-C to LLVM IR.

Using Clang allows us to do many things that Perl is not capable of. Most notably, clang-logos can emulate instance variables. Using @synthesize inside of an @hook container will generate getters and setters for an object, using Objective-C associative references. Non-object types such as structs and scalars (int, float, etc) are automatically wrapped in NSValue (this is transparent to the user).

Clang-logos also inserts code to calculate the offset of instance variables at runtime, for ivars referenced within an @hook container. This eliminates the need for MSHookIvar.

Clang-logos is still under development, and many features are yet to come. The information below is subject to change.

Building clang-logos
Building clang-logos is the same as building normal Clang. The source can be downloaded from eswick's GitHub.

See the official documentation for instructions on building.

Examples
Clang-logos syntax is slightly different than original Logos.

For proper usage, header of the class you're hooking should be in an external file, separate from the file containing the hooks. This header typically comes from class-dump.

The hooking code should go in a normal Objective-C file, with an extension of .m / .mm

Running clang-logos
Compiling clang-logos source code is the same as compiling normal Objective-C, with one exception; the '-fobjc-logos' flag must be specified. When linking source compiled with clang-logos, it must be linked against libsubstrate.