Generate “Finder.h” for a SIMBL plugin
Domanda
I'm trying to create a SIMBL plugin for Finder to add icon overlay over some files.
I have this code:
@implementation NSObject (FAIconOverlay)
- (void)FAIconOverlay_TIconAndTextCell_drawIconWithFrame:(struct CGRect)arg1
{
[self FAIconOverlay_TIconAndTextCell_drawIconWithFrame:arg1];
if (![self respondsToSelector:@selector(node)]) {
return;
}
NSLog(@"%@", [[[NSClassFromString(@"FINode") nodeWithFENode:[(TNodeIconAndNameCell *)self node]] fullPath] lastPathComponent]);
// Draw the icon overlay
}
- (void)FAIconOverlay_TDesktopIcon_drawIconInContext:(struct CGContext *)arg1
{
[self FAIconOverlay_TDesktopIcon_drawIconInContext:arg1];
}
@end
I can draw the icon overlay but, when I try to get the path of the file I get a "Use of undeclared identifier TNodeIconAndNameCell". Looking this link < How to Write OS X Finder plugin > I see that is neccessary to generate a Finder.h file...
My question is: How to generate this file?? I tried running "class-dump -H Finder.app" but I get too more compiling errors
Thank you very much!
Soluzione 3
The solution is not include all the headers generated by class-dump (to now how to generate this headers check the @jackjr300 answer). Only is necessary included the used headers and fix the compiling problems.
Altri suggerimenti
To create a "Finder.h" :
sudo class-dump -H -o /output_directory/Path /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
Instead of overriding the drawIconWithFrame: method of TIconAndTextCell, you should override the drawIconWithFrame: method of TNodeIconAndNameCell.
Class finder_class = [objc_getClass("TNodeIconAndNameCell") class];
class_addMethod(finder_class, @selector(FT_drawIconWithFrame:),
class_getMethodImplementation(self_class, @selector(FT_drawIconWithFrame:)),"v@:{CGRect={CGPoint=dd}{CGSize=dd}}");
old = class_getInstanceMethod(finder_class, @selector(drawIconWithFrame:));
new = class_getInstanceMethod(finder_class, @selector(FT_drawIconWithFrame:));
method_exchangeImplementations(old, new);
And then you can do this:
NSLog(@"%@", [[[NSClassFromString(@"FINode") nodeWithFENode:[self node]] fullPath] lastPathComponent]);