I want to make a very basic SIMBL Plugin - just add a new Menu in Safari. This is what I've tried: I added this to my plist:
<key>NSPrincipalClass</key>
<string>MySamplePlugin</string>
<key>SIMBLTargetApplications</key>
<array>
<dict>
<key>BundleIdentifier</key>
<string>com.apple.Safari</string>
<key>MaxBundleVersion</key>
<string>*</string>
<key>MinBundleVersion</key>
<string>*</string>
</dict>
</array>
Then i created the MySamplePlugin classes and a Menu.xib. (All connections are made this can't be the mistake) my .h
-(IBAction)clickAbout:(id)sender;
@property (assign) IBOutlet NSMenu *topMenu;
and my .main file
- (id) init {
self = [super init];
if (! self)
return nil;
[NSBundle loadNibNamed: @"Menu.xib" owner: self];
return self;
}
- (IBAction) clickAbout: (id) sender {
NSLog(@"do some stuff here");
}
+ (void) load
{
MySamplePlugin* plugin = [MySamplePlugin sharedInstance];
NSMenuItem* item;
item = [[NSMenuItem alloc] init];
[item setSubmenu: [plugin topMenu]];
[[plugin topMenu] setTitle: @"George"];
[[NSApp mainMenu] addItem: item];
NSLog(@"MySamplePlugin installed");
}
+ (MySamplePlugin*) sharedInstance
{
static MySamplePlugin* plugin = nil;
if (plugin == nil)
plugin = [[MySamplePlugin alloc] init];
return plugin;
}
Any idea why my plugin is not working ? It builds without warnings and i copy it to ~/Library/Application Support/SIMBL/Plugins/
And this is my console.app output: http://cl.ly/LsH9
Nevermind i got it with this little code modification:
NSMenu* mainMenu = [NSApp mainMenu];
NSMenu* debugMenu = [[NSMenu alloc] initWithTitle:@"Menu"];
NSMenuItem* newItem = [[NSMenuItem alloc] initWithTitle:@"Item" action:nil keyEquivalent:@""];
[newItem setSubmenu:debugMenu];
[mainMenu addItem:newItem];
[debugMenu addItemWithTitle:@"Run Unit Tests" action:nil keyEquivalent:@""];