Objective-c obfuscation of methods works in DEBUG but crashes in RELEASE Objective-c obfuscation of methods works in DEBUG but crashes in RELEASE objective-c objective-c

Objective-c obfuscation of methods works in DEBUG but crashes in RELEASE


Where have you placed the #define for obfuscation ? Is it in the header file (.h) or in the implementation file (.m) of the framework ?

For the obfuscation to be effective, it must be placed in a file that is both included by the implementation and the caller.

You can also check that the pre-processing is ok by inspecting the pre-processed file. Select the implementation file and go to the menu Product > Generate Output > Generate Preprocessed File (you can select the configuration at the bottom of the screen).


My hunch is the #define location/visibility as well.

But you may want to consider this from another angle. You could change:

#define specialMethod a9328238+(void) specialMethod{   // do security stuff}

to:

@interface SecurityClass : NSObject// private obfuscated interface:+ (void)a9328238;// {//    do security stuff in a9328238's definition// }@end// here is the public interface:static inline void SecurityClass_LogIn() {   [SecurityClass a9328238];}

dropping #define altogether.

In use:

SecurityClass_LogIn();…

Since this is a class method, you could write an obfuscated function wrapped in a human readable inline instead. A well crafted C implementation will be much more difficult to pick apart than objc.

A more complete example would help us narrow down the possibilities.

Also verify there are no warnings -- the compiler may warn you if you have called an undeclared selector. It's possible that the method is called where the #define is not visible in other cases.


It seems that the executable which imports the obfuscated framework tries to access the non-obfuscated methods.

You should check the symbols in the framework. Use nm on the static library in the framework to see the exported symbols (marked with a 't'). Make sure the symbols are obfuscated.