This page is an archived version of http://quicksilver.infogami.com/ObjectiveCPlugInsBasicTutorial
Quicksilver
Basic Tutorial (Draft)
Introduction
A brief tutorial showing the creation, installation, and running of a Quicksilver plug-in (Objective-C) implementing a simple action.
Set-up
Ensure a development version of Quicksilver is installed (I put mine under ~/Applications/).
Ensure Developer Tools is installed (I’ve got whichever one gives me Xcode 2.4).
Follow the plug-in template installation instructions (Note that there is an important step involving telling Xcode where certain Quicksilver frameworks live – hint: they live inside the development version of Quicksilver which should now be installed.).
Implementation
Launch Xcode if it’s not already launched.
From the Assistant (or File -> New Project), choose to create a ‘Quicksilver Plug-in’ (You’ll likely choose a location for your project and a name — I’m going to use ‘MyPlugIn’ as a name for this tutorial).
Edit Info.plist to make the content as follows (A plug-in’s Info.plist allows a plug-in to communicate details about itself to Quicksilver (e.g. whether the plug-in provides an action)):
< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Edit MyPlugIn.h to make the content:
//
// MyPlugIn.h
// MyPlugIn
//
#import
@interface MyPlugInActionProvider : NSObject
{
}
@end
Edit MyPlugIn.m to make the content:
//
// MyPlugIn.m
// MyPlugIn
//
#import “MyPlugIn.h”
#import
#import
#import
@implementation MyPlugInActionProvider
– (QSObject *) performMyAction:(QSObject *)dObject
{
NSString *text = [dObject objectForType:QSTextType];
NSAssert1(text, @”Error: failed to obtain string from: %@”, dObject);
NSDictionary *attributes = \
[NSDictionary dictionaryWithObjectsAndKeys:@”My Action”, QSNotifierTitle,
text, QSNotifierText, nil];
NSAssert(attributes, @”Error: failed to create dictionary for notification”);
QSShowNotifierWithAttributes(attributes);
return nil;
}
@end
Save your changes.
Build (this should result in the creation of ‘MyPlugIn.qsplugin’).
Installation
Double-click MyPlugIn.qsplugin to initiate plug-in installation.
Answer appropriately when asked by Quicksilver about installing (Plug-ins are installed under ~/Library/Application Support/Quicksilver/).
Testing/Running
Ensure Quicksilver is running.
Activate Quicksilver.
Enter text entry mode (hint: use the period key).
Type some text (how about ‘Would you like to play a green vegetable?’ ?)
Choose ‘My Action’ as the action.
Press the return key.
If all went well, you should be notified by Quicksilver of the text you entered via text entry mode (If not, time to check out Console.app).
References
- Blacktree Wiki Docs
- Blacktree Forums
- #quicksilver IRC
- QS Framework Headers — dig under ~/Applications/Quicksilver.app/Contents/Frameworks/
- Installed plug-ins — ~/Library/Application Support/Quicksilver/
- Brief PyObjC plug-in document – a bit dated but still of some use
- Detailed PyObjC plug-in document – a bit dated but still of some use