我想制作一个非常基本的 SIMBL 插件 - 只需在 Safari 中添加一个新菜单。这是我尝试过的:我将此添加到我的 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>
然后我创建了 MySamplePlugin 类和 Menu.xib。(所有连接都已建立,这不会是错误)我的 .h
-(IBAction)clickAbout:(id)sender;
@property (assign) IBOutlet NSMenu *topMenu;
和我的 .main 文件
- (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;
}
知道为什么我的插件不工作吗?它在没有警告的情况下构建,我将其复制到 ~/Library/Application Support/SIMBL/Plugins/
这是我的 console.app 输出:http ://cl.ly/LsH9