tsmac
tsmac

Reputation: 1

Prevent Headers dump through executable in cocoa osx app

I am doing experiments on my cocoa mac application ,found I can dump all header files (.h files) of my application executable file using another class-dump executable available on Github.

I want to know how can I prevent my application from header files dump using any 3rd party executable like class-dump.

Command for Dumping:

./class-dump -H /Users/abc/Documents/app -o ./Headerfiles

Any Suggestions

Thanks in Advance

Upvotes: 0

Views: 178

Answers (1)

James Bucanek
James Bucanek

Reputation: 3439

I doubt there's any way to prevent this.

Objective-C class, method, property, protocol, and category information is all registered dynamically at runtime. Therefore, your executable's __DATA section must contain all of this information. Tools like class-dump simply reverse engineer these tables to create an equivalent interface (.h) file.

The only way to get around this would be to programmatically create your classes at runtime, which in my opinion would be just crazy.

An ugly, half-solution—full of potential problems—would be to try some form of code obfuscation:

#define MyClass m0
#define doSomething m1
#define userClickedButton m2
#define hitCount m3

@interface MyClass
- (void)doSomething;
- (IBAction)userClickedButton:(id)sender;
@property NSUInteger hitCount;

would appear in the compiled application as

@interface m0
- (void)m1;
- (void)m2:(id)o;
- (unsigned long)m3;
- (void)setM3:(unsigned long)n;

Upvotes: 1

Related Questions